需要一些技巧,保存索引:
chart.listen(anychart.enums.EventType.ROW_MOUSE_DOWN, function(e) {
var treeDataItem = e.item;
absoluteSourceIndex = treeDataItem.meta('index');
});
然后你像这样:
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);
});
这是一个工作示例:https ://jsfiddle.net/mhm7hbsb/1/