TreeGrid get data from selected boxes

Hello,

i have a problem, i need to use the checkbox selection.

How do i get all the selected rows to an array.

is there a function to call to see what the user has selected?
I´ve tried the selectedRows but its allways triggered on click in the row.


greetings.

3 Replies

JS Jonesherine Stephen Syncfusion Team November 24, 2016 03:17 PM UTC

Hi Ruzic, 
Thanks for contacting Syncfusion support 
Query: How do i get all the selected rows to an array.is there a function to call to see what the user has selected? 
Solution: In “selectedItems“property we can get the checked records collection in TreeGrid. We have prepared the sample and alerted the checked record length for your reference. 
Please find the code example below: 
  <button onclick="clickme()" style="margin-bottom:10px">Checked Items</button> 
<script type="text/javascript"> 
  function clickme() { 
            var treeObj = $("#TreeGridContainer").ejTreeGrid("instance"), 
                //to get the checked items collection 
            checkedItems = treeObj.model.selectedItems; 
            alert(checkedItems.length); 
        }     
</script> 
Please find the sample from below location 
 
Regards, 
Jone sherine P S 



RI RI November 28, 2016 03:19 PM UTC

Perfect!!!!!!

Thank you.

is there a way to unselect the boxes after
treeObj.refresh(); ?


JS Jonesherine Stephen Syncfusion Team November 29, 2016 06:03 PM UTC

Hi Ruzic, 
By using “selectAllRows” public method we can check/uncheck the records in TreeGrid. For this we need to set “enableSelectAll” property as true in selectionSettings. 
Please find the code example below: 
<button onclick="uncheck()">To Uncheck</button> 
function uncheck() {            
            var treeObj = $("#TreeGridContainer").ejTreeGrid("instance"); 
                //to get the checked items collection 
            treeObj.selectAllRows(false);            
        } 
We have also prepared the sample based on this. Please find the sample from below location 
 
Regards 
Jone sherine P S 


Loader.
Up arrow icon