Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get selected item from kendo treeview in javascript

I'm trying to get the selected item with a specific id from outside of the kendo treeview. Basically, I'm writing a js function to try to find out which node is selected. Is there a way to find out which node (and it's datasource properties) can be extracted?

I can get the node data if the an event listener passes the event but can't figure out a way to get to that node without the event listener.

Once I get that data, I would like to update some button links to go to the next item in the node.

//get node WITH listener:
function getNode(e){
    var nodedata = $('#treeName').getKendoTreeView().dataItem(e.node).id;
    console.log(nodedata);
}

//BUT I want to find out from outside of Kendo treeview with something like this:
function getNode() {
    var getSelectedId = $('#treeName').getKendoTreeView().getCurrentSelectedItem().id
    console.log(getSelectedId);
}
like image 874
Chuck Avatar asked Nov 23 '25 00:11

Chuck


1 Answers

It's pretty straightforward. Just use

$('#treeName').data("kendoTreeView").select().data().id
like image 157
Sangram Nandkhile Avatar answered Nov 24 '25 21:11

Sangram Nandkhile