copy

copies an item to the same or another object

void copy(id sid,number tindex, [object tobj,object details] );
sididthe id of the copied object
tindexnumberthe index of the copy
tobjobjectthe object that an item is copied to
detailsobjectextra parameters for copying

Example

gridb.attachEvent("onBeforeDrop", function(context, ev){
    for (var i=0; i< context.source.length; i++){
        context.from.copy(context.source[i],context.index,this,{newId:webix.uid()});
    }
    return false;
});

Related samples

Details

In the sample above:

  • sid is the ID of each dragged item;
  • tindex is the index of a copy;
  • tobj is a datatable object where the items are dropped to;
  • newId is generated automatically with the webix.uid() method.

The details object can contain the following properties:

details = {};
details.newId = "123"; // a new id for the moved item

Note that in case newId is not defined, the new ID will be the same as the ID of the source item (sid), which is not desirable while copying takes place within one and the same component.

See also
Back to top
If you have not checked yet, be sure to visit site of our main product Webix html5 ui library and page of datatable js product.