I have the following scenario: a list and a datatable both have the DnD feature enabled. The IDs of records is a part of visible data, but when I try to place items with equal IDs into one view, id becomes a randomly-generated one. As I want to perform a copy
operation for data items, here's a question: how to prevent copying of items that already exists in the target datatable?
Here's my code https://jsfiddle.net/gL72d02c/
Copying implemented according to the sample in documentation, i.e.
$$("view").attachEvent("onBeforeDrop", function(context, ev){
for (var i=0; i< context.source.length; i++){
context.from.copy(context.source[i],context.start,this,webix.uid());
}
return false;
});
答案 0 :(得分:0)
您需要做的就是检查目标小部件中是否有此类ID exists(文档)。即:
$$("petTable").attachEvent("onBeforeDrop", function(context, ev){
for (var i=0; i< context.source.length; i++){
if (this.exists(context.source[i]))
return false;
context.from.copy(context.source[i],context.start,this,webix.uid());
}
return false;
});