I tried using the move example included here and e.itemIndex is undefined. My initial exploration of the e object fails to find an item index attribute. I would like to know the old index of the item being moved and the new index of the item.
var tree = anychart.data.tree(getData(), anychart.enums.TreeFillingMethod.AS_TABLE);
tree.listen(anychart.enums.EventType.TREE_ITEM_MOVE, function(e){
chart.title.text("The "+e.itemIndex+" item was moved");
});
See my fiddle here: http://jsfiddle.net/ax2t5hvt/
Some trickery is needed, save the index:
chart.listen(anychart.enums.EventType.ROW_MOUSE_DOWN, function(e) {
var treeDataItem = e.item;
absoluteSourceIndex = treeDataItem.meta('index');
});
and then you go like this:
treeData.listen(anychart.enums.EventType.TREE_ITEM_MOVE, function(e) {
/*
Event e contains the following useful fields:
e.type - Event type
e.item - Moved item.
e.target - Target data item that becomes a parent of the moved item.
If is null, the parent is tree itself and moved item becomes root.
e.targetIndex - Index of moved item in target item
(or in roots of tree if e.target is null)
e.source - Source data item, where the item moved from.
e.sourceIndex - Old index of the moved item of the previous parent.
*/
var treeDataItem = e.item;
alert('Old absolute index: ' + absoluteSourceIndex + '\n' +
'New absolute index: ' + treeDataItem.meta('index') + '\n' +
'Old index in old parent tree data item: ' + e.sourceIndex + '\n' +
'New index in new parent tree data item: ' + e.targetIndex);
});
Here is a working sample: https://jsfiddle.net/mhm7hbsb/1/