How to mark a Treeview node as selected on server?

2 posts, 0 answers
  1. Adrian
    Adrian avatar
    1 posts
    Member since:
    Jun 2011

    Posted 03 Oct 2013 Link to this post

    Hi all
    Due to technical reason we have to fully postback our ASP.NET MVC view. This view contains a Kendo TreeView which will be loaded and bound in the view to the model as follow:
    ourModel is:
    It seems that there is no property 'selected' in this TreeViewItemModel class. So my question is: Is it possible to select a TreeView Node on server side? If not what would be a good solution to preserver selected Node during postback?

    Thanks for help

  2. Daniel
    Daniel avatar
    2174 posts

    Posted 07 Oct 2013 Link to this post

    Hello Adrian,

    Indeed, the Selected property is currently missing and we will include it for the next internal build. For now, in order to set the selected node on the server I can suggest to use the ItemAction callback:

    .ItemAction(item =>
        if (item.Id == SelectedID)
            item.Selected = true;
    or explicitly specify the binding:
    .BindTo(ourModel, mapping => mapping
        .For<TreeViewItemModel>(binding => binding
            .ItemDataBound((item, node) => {
                item.Selected = node.Id == SelectedID;
                item.Text = node.Text;
                item.Id = node.Id;
                //assign all used properties                       
            .Children(item => item.Items))
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top