I have a TreeView implementation that often contains hierarchies that have large numbers of nodes in very flat structures. While I have drag and drop working, the usability just isn't very good. So, I'm implementing a cut/paste mechanism where the cut simply remembers the unique id of the source node and on paste of the target node, I get the source node using its id and attempt to .append(sourceNode, targetNode).
However, this doesn't seem to work.
Is this the best way to approach this or is there a different way I should approach this?
$("#mnuHierarchyRightClick").kendoContextMenu({
target: "#tvHierarchy",
filter: ".k-in",
select: function (e)
{
switch (e.item.id)
{
case "mnuHierarchyRightClickCut":
var tv = $("#tvHierarchy").data("kendoTreeView");
var dataItem = tv.dataItem(e.target);
self.setClipBoard(dataItem.ID,'Clipboard: ' + dataItem.Text);
break;
case "mnuHierarchyRightClickPaste":
self.paste(e.target);
break;
default:
break;
};
}
});
// called from click on context menu of the TreeView
MyController.prototype.paste = function (targetNode)
{
var self = this;
try
{
var tv = $("#tvHierarchy").data("kendoTreeView");
if (targetNode == null) { return false; }
var targetDataItem = tv.dataItem(targetNode);
var pastedDataItem = tv.dataSource.get(self.ClipBoardPrimaryKeyID);
self.setClipBoard(0,'');
var pastedNode = tv.findByUid(pastedDataItem.uid);
pastedDataItem.set('parentID', targetDataItem.id);
tv.append(pastedNode,targetNode);
}
catch(e)
{
alert(e);
}
}