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

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

4 Answers 154 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Gers
Top achievements
Rank 1
Gers asked on 18 Jan 2016, 07:56 PM

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);
        }    

4 Answers, 1 is accepted

Sort by
0
Gers
Top achievements
Rank 1
answered on 18 Jan 2016, 08:04 PM

 ( erratum)

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

 e.sender.select(test1)
    

0
Gers
Top achievements
Rank 1
answered on 18 Jan 2016, 08:11 PM
I have an error in the title of the thread, what I wanted was "Select a node by default in a Treelist"
0
Boyan Dimitrov
Telerik team
answered on 21 Jan 2016, 04:01 PM

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!
 
0
Gers
Top achievements
Rank 1
answered on 22 Jan 2016, 02:50 PM
Perfect, thank you
Tags
TreeList
Asked by
Gers
Top achievements
Rank 1
Answers by
Gers
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or