Hi WebixTeam,
I have a code like below
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);
}},
]});
}},
]
}
]
}
});
If click on the add view button row is getting added with combo and textbox ,
Now when i click on the trash icon row is getting deleted.
Now when i click on the add button again the row is not getting added.
How can i solve this bug in my code ??
Anybody please help me …