Moving Items by API

Moving

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:

view.moveUp(id)
view.moveUp(id,step);
 
view.moveDown(id)
view.moveDown(id,step)
 
view.moveTop(id)
 
view.moveBottom(id)

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);
//or
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.

Copying

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);
//or
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);
//or
view.copy(source_id, index, null, target_id);
//or
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