Selecting multiple row (with checkbox option) at initial loading of tree grid

i want to select multiple row initialy selected at tree grid. i looked at documentation, it says:

Selecting a row at initial load

You can select a row at initial load by setting the index of the row to the selectedRowIndex property.

Find the following code for selecting a row at initial load.

$("#TreeGridContainer").ejTreeGrid({
        //... 
        selectedRowIndex: 3,
   });
this is for just one row. i need multiple row selected.

1 Reply

SR Suriyaprasanth Ravikumar Syncfusion Team November 24, 2017 11:21 AM UTC

Hi Ugur, 

We can able to achieve your requirement by using “selectRows” public method and “create” client side event. 
Create – Event which is triggered when TreeGrid is rendered completely 
Please refer the code snippet below. 
[HTML] 
         $(function () { 
            $("#TreeGridContainer").ejTreeGrid({ 
                dataSource: sampleData, 
                //.. 
                create: "create", 
           }); 
        }); 
 
        function create(args) { 
            var obj = $('#TreeGridContainer').data("ejTreeGrid"), 
                rowindex = [2,4,6]; // row index 
                for(var x = 0; x < rowindex.length; x++){ 
                      obj.selectRows(rowindex[x],null,true); //(rowIndex, toIndex, isCheckbox) 
                 } 
        } 

Please find the sample link below. 

Please let us know if you need any other assistance on this.  
 
Thanks,  
Suriyaprasanth R. 


Loader.
Up arrow icon