coldistric
coldistric

Reputation: 303

How to programatically select a node in a treeList (Kendo)

Is there a way to select a node in a treeList by default ?

How can I select a node in a treeList programmatically ?

Is there a method similar to findByUid as in a treeView ?

Upvotes: 0

Views: 4780

Answers (2)

The_Black_Smurf
The_Black_Smurf

Reputation: 5269

If you want to select a Node by default, you can do it by setting the node's selected property to true when you initialise the dataSource. Another option would be to call the TreeView select() method after the TreeView completed the data loading. (See the dataBound event for more details since the TreeView initialization may be completed before the data gets fully loaded)

For the selection, there's a findByUid method that can be used in the TreeView. The findByUid function will return the jQuery nodes matching the specified uid. You can then use the results to select a node programatically by using the select() method:

var dataItem = treeview.dataSource.get(10);
var node = treeview.findByUid(dataItem.uid);
treeview.select(node);

Upvotes: 1

DontVoteMeDown
DontVoteMeDown

Reputation: 21465

Sure, there is a method called select():

var tr = $("#treelist .k-grid-content tr:first"); // The row
$("#treelist").data("kendoTreeList").select(tr);

The method accepts only a tr element.

Demo.

Upvotes: 0

Related Questions