Streeview.select(selectitem);elect a node by default in a treelist

5 posts, 0 answers
  1. Gers
    Gers avatar
    10 posts
    Member since:
    Jan 2016

    Posted 18 Jan Link to this post

    Is there a way to select a node by default in a Treelist ? eg :if a node has "selected" set to true in the datasource, kendo will automatically select the node.

    If not, How can I select a node programmatically in a Treelist ?

    I've searched on the internet , all the results that I've found are about TreeView.

    I've tried the same method as in treeView, but there is not a method named "findByUid"

     

     "onSelect": function (e) {

            var selectedRows = this.select();
            var selectedDataItems = [];
            for (var i = 0; i < selectedRows.length; i++) {
                var dataItem = this.dataItem(selectedRows[i]);

                if (!dataItem.selectable)
                {
                    //hack 
                    //For now, a treelist doesn't allow you to prevent the selection 
                    //as it is done in a treeview (e.preventdefault).So in order
                    // to prevent the selection we must do a little hack using css.
                    selectedRows.removeClass("k-state-selected");
                
                }

                //test
                e.sender.select(e.sender.findByUid(2));

        treeview.select(selectitem);
            }    

  2. Gers
    Gers avatar
    10 posts
    Member since:
    Jan 2016

    Posted 18 Jan in reply to Gers Link to this post

     ( erratum)

    //test
     var test1 = e.sender.select(e.sender.findByUid(2));

     e.sender.select(test1)
        

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gers
    Gers avatar
    10 posts
    Member since:
    Jan 2016

    Posted 18 Jan Link to this post

    I have an error in the title of the thread, what I wanted was "Select a node by default in a Treelist"
  5. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 21 Jan Link to this post

    Hello Gers,

     

    The Kendo UI TreeList does have a select method that gets or sets the table rows (or cells) which are selected.

     

    Please take a look at examples below the article that shows how to select programmatically a table row. Please note that the uid value is applied to the table row element. Given this using jQuery you are able to find the table row element by the uid value (if you know that value) and pass the table row element to the select method. 

     

    Regards,
    Boyan Dimitrov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Gers
    Gers avatar
    10 posts
    Member since:
    Jan 2016

    Posted 22 Jan Link to this post

    Perfect, thank you
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017