The TreeView displays hierarchical data in a traditional tree structure. It supports user interaction through the mouse or touch to perform re-ordering operations via drag-and-drop.
A TreeView can be created by leveraging HTML lists. However, it does not support binding to a remote data source at this point in time.
A TreeView can be created in two ways:
Static HTML definition is appropriate for small hierarchies and for data that does not change frequently. Databinding should be used for larger data sets and for data that changes frequently.
<ul id="treeView">
<li>Item 1
<ul>
<li>Item 1.1</li>
<li>Item 1.2</li>
</ul>
</li>
<li>Item 2</li>
</ul>Initialization of a TreeView should occur after the DOM is fully loaded. It is recommended that initialization the TreeView occur within a handler is provided to $(document).ready().
$(document).ready(function() {
$("#treeView").kendoTreeView();
});<div id="treeView"></div>$(document).ready(function() {
$("#treeView").kendoTreeView({
dataSource: [
{
text: "Item 1",
items: [
{ text: "Item 1.1" },
{ text: "Item 1.2" }
]
},
{ text: "Item 2" }
]
})
});Currently, the TreeView does not support binding to a remote data source.
var item = {
text: "Item text",
// renders a <img class="k-image" src="/images/icon.png" />
imageUrl: "/images/icon.png",
// renders a <span class="k-sprite icon save" />
spriteCssClass: "icon save",
// specifies whether the node text should be encoded or not
// useful when rendering node-specific HTML
encoded: false,
A number of <strong>TreeView</strong> behaviors can be easily controlled by simple configuration properties,
such as animation behaviors and drag-and-drop behaviors.
</p>$("#treeView").kendoTreeView({
dragAndDrop: true
});When drag-and-drop is enabled, the nodes of a TreeView can be dragged and dropped between all levels, with useful tooltips helping indicate where the node will be dropped.
You can reference an existing TreeView instance via jQuery.data(). Once a reference has been established, you can use the API to control its behavior.
var treeView = $("#treeView").data("kendoTreeView");