We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Getting all selected rows

Hello,

How to get all selected rows of the TreeGrid by javascript?

Thanks!

5 Replies

DK Dinesh Kumar Nagarathinam Syncfusion Team November 24, 2015 12:58 PM UTC

Hi Jorge,

In TreeGrid control multiple selection will be done only in the view, the rows or the records are not preserved but we can get the selected rows in TreeGrid using the “RowSelected” client side event.

Code Snippet:


<ej:TreeGrid ID="Treegrid" runat="server" AllowColumnResize="true"

RowSelected="rowSelected">

</ej:TreeGrid>

<script type="text/javascript">

            var selectedRows = [], selectedRecords = [];

            function rowSelected(args) {                         

                var treeObj = $("#Treegrid").data("ejTreeGrid"),              

                    selectedRowIndex = treeObj.selectedRowIndex();

                selectedRows.push(args.targetRow[0]);

                selectedRecords.push(treeObj.model.updatedRecords[selectedRowIndex]);

            }                     

        </script>




We have prepared a sample base on your requirement, find the sample from below location.

Sample: http://www.syncfusion.com/downloads/support/forum/121242/ze/Multiple_selected_row_collection-10427508

Regards,

Dinesh kumar.N



JP Jorge Pampin November 24, 2015 04:35 PM UTC

Hello,

This is a big problem. If you can select more than one row, you should access to all selected rows.... In the sample, what about if you unselect rows?

Thanks!


DK Dinesh Kumar Nagarathinam Syncfusion Team November 25, 2015 11:46 AM UTC

Hi Jorge,

Sorry for the inconvenience caused.

At present there is no support to maintain all selected/unselected rows in TreeGrid for multiple row selection. For this we have already logged a usability feature request regarding this. A support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents

But we can achieve this by using “RowSelecting” client side event.

Code Snippet:


<ej:TreeGrid ID="Treegrid" runat="server" AllowColumnResize="true" 

RowSelecting="rowSelecting">

</ej:TreeGrid>

<script type="text/javascript"> 

            var selectedRows = [], selectedRecords = [];

            function rowSelecting(args) {                          

                var index = selectedRecords.indexOf(args.data);              

                if (index == -1) {

                    selectedRows.push(args.targetRow[0]);

                    selectedRecords.push(args.data);

                }

                else

                {                   

                    selectedRows.splice(index, 1);

                    selectedRecords.splice(index, 1);

                }        

        }                      

        </script>



We have prepared a sample based on your requirement, find the sample from below location.

Sample: http://www.syncfusion.com/downloads/support/forum/121242/ze/Multiple_Rows-265163837

Regards,

Dinesh kumar.N



JP Jorge Pampin January 21, 2016 05:04 PM UTC

Hello,

With the current version, can I access to the selected rows by javascript?

Thanks!


MK Mahalakshmi Karthikeyan Syncfusion Team January 22, 2016 12:47 PM UTC

Hi Jorge,

Please follow up with incident created under your account regarding this feature.

Regards,

Mahalakshmi K.


Loader.
Up arrow icon