Hi
I do have below webix code
When i click on the add button and a row is getting added with combo
and textbox
if the user selects only year1 as value from the combo then the textbox should accept only integers if the user selects any other value other than year1 it should accept any.
Please help me .how can i do this??
var a = [
{id:"movie",value:"Movie Name",type:"string"},
{id:"movieplace", value:"movieplace", type:"string"},
{id:"year", value:"year1", type:"string" }
];
const removed = [];
webix.ui({
view:"window",
id:"moviewin",
height:300,
width:700,
modal:true,
position:"center",
head:"Movie data",
hidden: false,
body:{
view:"form",id:"movieform",width:600, scroll: true,
elements:[{
view: "layout",
cols:[
{
view:"combo",
id:"moviedata",
label:"Fields",
options:a
},
{
view:"text",
label:"Value"
},
]
},
{
cols:[
{view:"button",
label:"Movie Data",
click:function(){
}},
{view:"button",
label:"Reset",
click:function(){
}},
{view:"button",
label:"Cancel",
click:function(){
}},
{view:"button",
label:"Add",
click:function(){
$$("movieform").addView({
view: "layout",
cols:[
{
view:"combo",
name:"co",
label:"Fields",
on:{
onChange: function(id){
let LastC = this.getList().getItem(id);
for (var i = 0; i < a.length; i++) {
if(a[i].value == LastC.value){
const item = a.splice(i,1)[0];
removed.push(item);
this.define("options",[item]);
}
}}
},
options:a
},
{
view:"text",
label:"Value"
},
{view:"icon", icon:"wxi-trash", click:function(){
let toRemove = this.getParentView();
const combo = toRemove.queryView("combo");
const combooption = combo.getValue();
const toAdd = removed.find(function(obj){
return obj.id == combooption;
});
a.push(toAdd);
this.getParentView().getParentView().removeView(toRemove);
}},
]});
}},
]
}
]
}
});