Hi,
I'm almost done with the code from the subject. The tree expands already to the given ID, but unfortunately it does not select the node given by ID
Edit: Just to clarify, because I read a few threads regarding this issue - I don't get any error messages nor do I get 'undefined' for any variables. The node just doesn't get selected.
I also tried $(treeView).select(item), since it should already point to the <span> item I want to select anyway. This didn't work.
Then I tried tried $(treeView).select(item.closest('.k-item')), since it points to the parent <li> element, but this didn't work either.
The uncommented line (treeView.select(".k-item:last")) was just for testing and works.
I'm a little bit stuck and glad about any hints.
I'm almost done with the code from the subject. The tree expands already to the given ID, but unfortunately it does not select the node given by ID
Edit: Just to clarify, because I read a few threads regarding this issue - I don't get any error messages nor do I get 'undefined' for any variables. The node just doesn't get selected.
function
expandAndSelectNode(id, treeViewName) {
// get the Kendo TreeView widget by it's ID given by treeviewName
var
treeView = $(treeViewName).data(
'kendoTreeView'
);
// find node with data-id = id
var
item = $(treeViewName).find(
"li[data-id='"
+ id +
"']"
).find(
".k-in"
);
// expand all parent nodes
$(item).parentsUntil(
'.k-treeview'
).filter(
'.k-item'
).each(
function
(index, element) {
$(treeViewName).data(
'kendoTreeView'
).expand($(
this
));
}
);
// get DataSourceItem by given id
var
nodeDataItem = treeView.dataSource.get(
id
);
//get node within treeview widget by uid
var
node = treeView.findByUid(nodeDataItem.uid);
$(treeView).select(node);
//treeView.select(".k-item:last");
}
I also tried $(treeView).select(item), since it should already point to the <span> item I want to select anyway. This didn't work.
Then I tried tried $(treeView).select(item.closest('.k-item')), since it points to the parent <li> element, but this didn't work either.
The uncommented line (treeView.select(".k-item:last")) was just for testing and works.
I'm a little bit stuck and glad about any hints.