var treeview = $("#treeView").data("kendoTreeView");
if(treeview){
treeview.select($());
var treeNodeData = treeview.dataSource.get(treeNodeId); // treeview.dataSource.options.data[1];
if(treeNodeData){
var treeNode = treeview.findByText(treeNodeData.text); //根据节点文本进行搜索(请根据实际情况来定),类似的还有treeview.findByUid(id);
if(treeNode){
treeview.select(treeNode); //设置节点选中,
}
}
}
参考地址: http://www.telerik.com/forums/programatically-select-a-tree-node
Hello Andrew,
To achieve this I can suggest the following approach:
- Get the dataItem via the get method of the dataSource;
- Use the findbyuid method of the TreeView, which searches a TreeView for a node with the given unique identifier;
- In the select method set the result from the previous step.
var
treeview = $(
"#treeview"
).data(
"kendoTreeView"
);
var
getitem = treeview.dataSource.get(9125);
treeview.findByUid(getitem.uid);
var
selectitem = treeview.findByUid(getitem.uid);
treeview.select(selectitem);
Regards,
Iliana Nikolovathe Telerik team