TreeView Nodes

4 posts, 1 answers
  1. Stid
    Stid avatar
    4 posts
    Member since:
    Aug 2007

    Posted 19 Aug 2011 Link to this post

    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
  2. Answer
    Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 22 Aug 2011 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Stid
    Stid avatar
    4 posts
    Member since:
    Aug 2007

    Posted 22 Aug 2011 Link to this post

    Yes it does, many thanks I hadnt spotted that.
  5. Richard
    Richard avatar
    3 posts
    Member since:
    Jan 2012

    Posted 26 Jan 2012 Link to this post

    I tried to do the same thing here but I got null returned?
Back to Top
Kendo UI is VS 2017 Ready