dear community,
I'm facing the following issue right now:
within my TreeView it should be possible, that every node and all its children can be copied within the same tree. Therefore I've setup a button which calls a function that tries to copy the node + its children.
The function looks like this:
function
CopyTreeViewItems() {
var
treeview = $(
'#treeview'
).data(
'kendoTreeView'
);
var
selectedNode = treeview.select();
var
data = treeview.dataItem(selectedNode);
var
newData = {
id: GenerateGuid(),
Name: data.Name +
"tmp"
};
treeview.insertAfter(newData, selectedNode);
var
parentItem = treeview.dataItem(treeview.findByText(newData.Name));
//<--- this part is returning 'undefined'
if
(data.hasChildren) {
var
children = data.children.data();
for
(
var
i = 0; i < children.length; i++) {
var
add = { id: GenerateGuid(), Name: children[i].Name };
treeview.append(add, parentItem);
}
}
}
The parent node is copied without any problems. If there are children of a parent node I'm not able to append them to the corresponding new parent.
Any advices?
Kind regards
Tom