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

TreeView Nodes

3 Answers 180 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Stid
Top achievements
Rank 2
Stid asked on 19 Aug 2011, 06:58 PM
Does the Treeview Node have an ID field -  if not it would be nice to use for a DB Primary Key (I have looked maybe missed it!)

but I think the whole set of controls are very clean and sleek - great work

3 Answers, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 22 Aug 2011, 01:18 PM
Hi Stid,

The TreeView has not an explicit ID field, but you can attach arbitrary data through the data- attributes.

<ul id="treeview">
    <li data-expanded="true" data-id="1">Item 1
        <ul>
            <li data-id="1.1">Item 1.1</li>
            <li data-id="1.2">Item 1.2</li>
            <li data-id="1.3">Item 1.3</li>
        </ul>
    </li>
    <li data-id="2">Item 2
        <ul>
            <li data-id="2.1">Item 2.1</li>
            <li data-id="2.2">Item 2.2</li>
            <li data-id="2.3">Item 2.3</li>
        </ul>
    </li>
    <li data-id="3">Item 3</li>
</ul>
 
<script>
    $(document).ready(function() {
        $("#treeview").kendoTreeView({
            select: function(e) {
                alert($(e.node).data("id"));
            }
        });
    });
</script>

Does this fit your case?

Kind regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Stid
Top achievements
Rank 2
answered on 22 Aug 2011, 01:43 PM
Yes it does, many thanks I hadnt spotted that.
0
Richard
Top achievements
Rank 1
answered on 26 Jan 2012, 04:30 PM
I tried to do the same thing here but I got null returned?
Tags
TreeView
Asked by
Stid
Top achievements
Rank 2
Answers by
Alex Gyoshev
Telerik team
Stid
Top achievements
Rank 2
Richard
Top achievements
Rank 1
Share this question
or