Set Selected Node

5 posts, 0 answers
  1. David
    David avatar
    2 posts
    Member since:
    Feb 2012

    Posted 06 Apr 2012 Link to this post

    When creating a treeview from hierarchical html, is there an attribute I can include on a <li> element to make it the selected node
  2. Richard
    Richard avatar
    148 posts
    Member since:
    Feb 2012

    Posted 08 Apr 2012 Link to this post

    Hi David:

    I don't think there is a configuration setting for such, and using an outright class='.k-state-selected' doesn't work because the .kendoTreeView method builds a scaffolding of html for displaying the original hierarchical data.

    Fiddle http://jsfiddle.net/yt8Mc/11/ shows how you can select and open to a original item having a 'show-me' class,
  3. David
    David avatar
    2 posts
    Member since:
    Feb 2012

    Posted 11 Apr 2012 Link to this post

    Thank-you, that worked great.
  4. Kyle
    Kyle avatar
    45 posts
    Member since:
    Mar 2012

    Posted 24 Apr 2012 Link to this post

    This works great when using HTML elements, but is there a solution when the data is loaded dynamically?
  5. Richard
    Richard avatar
    148 posts
    Member since:
    Feb 2012

    Posted 24 Apr 2012 Link to this post

    Add a property 'selected' to the dataSource.

    $('#datatree').kendoTreeView({
        dataSource: [
            {
            text: "Item 1",
            selected: true,
            items: [
                {
                text: "Item 1.1"},
            {
                text: "Item 1.1",
                selected: true},
            {
                text: "Item 1.2"}
            ]},
        {
            text: "Item 2"}
        ]
    });

    Hope that helps
Back to Top