Show Lines between the TreeView Nodes
Environment
Product | Progress® Kendo UI® TreeView for jQuery |
Operating System | Windows 10 64bit |
Visual Studio Version | Visual Studio 2017 |
Preferred Language | JavaScript |
Description
How can I show lines between the nodes of the Kendo UI for jQuery TreeView?
Solution
Depending on the TreeView rendering and styling options that you use, apply either the solution for the new rendering or the old rendering.
New Rendering
The following example demonstrates how to achieve the desired scenario.
<div id="treeview"></div>
<script>
$("#treeview").kendoTreeView({
dataSource: [
{ text: "Furniture", items: [
{ text: "Tables & Chairs" },
{ text: "Sofas" },
{ text: "Occasional Furniture" }
] },
{ text: "Decor", items: [
{ text: "Bed Linen" },
{ text: "Curtains & Blinds" },
{ text: "Carpets" }
] }
]
});
</script>
<style>
body {
font-size: 12px;
}
.k-treeview .k-treeview-top,
.k-treeview .k-treeview-mid,
.k-treeview .k-treeview-bot {
background-image: url('https://d35islomi5rx1v.cloudfront.net/mvc/2012.2.607/Default/treeview-nodes.png');
background-repeat: no-repeat;
margin-left: -16px;
padding-left: 16px;
}
.k-treeview .k-treeview-item { background-image: url('https://d35islomi5rx1v.cloudfront.net/mvc/2012.2.607/Default/treeview-line.png'); }
.k-treeview .k-treeview-last { background-image: none; }
.k-treeview .k-treeview-top { background-position: -91px 0; }
.k-treeview .k-treeview-bot { background-position: -69px -22px; }
.k-treeview .k-treeview-mid { background-position: -47px -44px; }
.k-treeview .k-treeview-last .k-treeview-top { background-position: -25px -66px; }
.k-treeview .k-treeview-group .k-treeview-last .k-treeview-bot { background-position: -69px -22px; }
.k-treeview .k-treeview-item {
background-repeat: no-repeat;
}
.k-treeview .k-treeview-first {
background-repeat: no-repeat;
background-position: 0 16px;
}
</style>
Old Rendering
This Dojo demonstrates how to achieve the behavior with versions earlier than R1 2022