select
Gets or sets the selected node.
Parameters
node jQuery|Element|String
(optional)
If provided, the node that should be selected.
Returns
jQuery
The currently selected node.
Example - select a node by passing an element
<div id="treeview"></div>
<script>
$("#treeview").kendoTreeView({
dataSource: [
{ text: "foo", items: [
{ text: "bar" }
] }
]
});
var treeview = $("#treeview").data("kendoTreeView");
var bar = treeview.findByText("bar");
treeview.select(bar);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(treeview.text(treeview.select())); // logs "bar"
treeview.select($()); // clears selection
</script>
Example - select a node by passing a jQuery selector
<div id="treeview"></div>
<script>
$("#treeview").kendoTreeView({
dataSource: [
{ text: "foo", items: [
{ text: "bar" }
] }
]
});
var treeview = $("#treeview").data("kendoTreeView");
treeview.select($(".k-treeview-item").last());
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(treeview.text(treeview.select())); // logs "bar"
</script>
Example - select a node by passing a string
<div id="treeview"></div>
<script>
$("#treeview").kendoTreeView({
dataSource: [
{ text: "foo", items: [
{ text: "bar" }
] }
]
});
var treeview = $("#treeview").data("kendoTreeView");
treeview.select(".k-treeview-item:last");
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(treeview.text(treeview.select())); // logs "bar"
</script>