This is a migrated thread and some comments may be shown as answers.

Treeview template and treeitem

1 Answer 270 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Richard asked on 19 Feb 2013, 07:56 PM
I have a remote data source (rds) that will deliver the tree view nodes items.
Elsewhere on the page there will be check boxes to allow the subtrees of various campaigns to be turned on and off.

The treeview template setting appears to only affect the 'k-in' span of a 'treeitem' li as rendered by the treeview control.

My situations is that the rds will supply additional item data about the nature of the item
{ id: ..., hasChildren: true, data:{addClass:'Campaign1'} }

I want the data.addClass value added to the class of the containing <li> that will be rendered.

The outcome desired looks like 
<li role="treeitem" class="k-item ... Campaign1" data-uid="..." id="...">
<div class="k-top/mid/bot"
<span class="k-icon ..." role="presentation"></span>
<span class="k-in"> TEMPLATE RENDERING GOES HERE </span>

Is there a way some javascript in the template setting can perform the desired tweak on the <li>?
Will I need to handle a 'children-loaded' event and iterate over the freshly rendered nodes ?

1 Answer, 1 is accepted

Sort by
Petur Subev
Telerik team
answered on 21 Feb 2013, 03:49 PM
Hello Richard,

Basically there is not built-in way to achieve this.

As a work-around I can suggest you to add Class to an invisible element inside of the template and when the dataBound occurs find the closest li to retrieve the actual model and the closest k-in to apply the class you desire to it.

Here is a demo which should give you the idea:

I hope this helps.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Asked by
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question