Check documentation for the latest version of dhtmlxSuite Moving Items by API DHTMLX Docs

Moving Items by API


There's a possibility to move items with the help of special methods. You may move the items to the very top/bottom of the dataview or move them up/down by the specified number of steps:


Items can also be moved to the specified position or to a different view by using the method move():

//move to the position
view.move(id, index);
//move to a different view
view.move(id, index, some_other_view);
view.move(id, null, some_other_view);
//move to different view and change the ID
//scenario may be needed to prevent the ID collision
view.move(id, index, some_other_view, target_id);

ID of the item is preserved while moving.


It's also possible to copy an item to the defined position. For this purpose the method copy() is used:

//make a copy of element
var new_id = view.copy(source_id);
//make a copy at the specific position
var new_id = view.copy(source_id, index);
//make a copy in a different view
var new_id = view.copy(source_id, index, some_other_view);
var new_id = view.copy(source_id, null , some_other_view);
//make a copy with the defined ID
view.copy(source_id, null, null, target_id);
view.copy(source_id, index, null, target_id);
view.copy(source_id, index, some_other_view, target_id);

The method returns the ID of the copied item which is autogenerated or can be specified as the last parameter.

Related sample:  Moving items within DataView Related sample:  Moving items between DataViews

Back to top