How to get selected rows Id's on click of button ?

I have to create a grid in which I want to get the selected rows Id's on button click so went through this link and I was able to add checkbox in my grid but I'm unable to get the required Id related to the selected rows. Please help. I do not want index number but the id(guid) which is attached with the row data on button click.

4 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team July 24, 2018 12:25 PM UTC

Hi Shalini, 

Thanks for contacting Syncfusion support. 

As per your given detail we suspect that you want to get the selected record from all the pages while using checkbox selection in Grid. 

We have already above mention query in the following knowledge base documentation. 


Regards, 
Thavasianand S. 



SH Shalini July 30, 2018 12:29 PM UTC

Yes i was able to work with that. But I got a slight glitch. When implementing your given scenario I ran into a problem where the checkbox selects all the records in the Grid. It means if the Grid has 2000 data then all will be selected. Is it possible to select only the records of a single page on click of a checkbox ? Because as of now if I want to select all the say 50 records of say page 1 , then I'll have to manually click 50 times. Cz if i click select all then all the records will be selected even of other page as well. Please help.


SH Shalini August 13, 2018 05:53 AM UTC

Is it possible to answer my question ? I have aasked something else as well and its been 13 days since my question was posted. Is it a feature or not or is it like development itself hasn't been made for the same ?  I ran into a problem where the checkbox selects all the records in the Grid. It means if the Grid has 2000 data then all will be selected. Is it possible to select only the records of a single page on click of a checkbox ? Because as of now if I want to select all the 50 records of page 1 , then I'll have to manually click 50 times. Cz if i click select all then all the records will be selected even of other pages as well. Please help.


PK Prasanna Kumar Viswanathan Syncfusion Team August 13, 2018 12:16 PM UTC

Hi Jessica, 

Sorry for the inconvenience caused. 

 Query : Is it possible to select only the records of a single page on click of a checkbox ? 
 
We have achieved your requirement using the rowSelecting event of grid. In rowSelecting event we have set the args.cancel as true if the header checkbox is clicked and have bind the click event to the header checkbox. In the click event of header checkbox we have selected the rows of the single page using selectRows method.  

Please refer the below code example. 


$("#Grid").ejGrid({ 
                // the datasource "window.gridData" is referred from jsondata.min.js 
                dataSource: window.gridData, 
                allowPaging: true, 
                rowSelecting:"rowSelecting", 
                columns: [ 
                        { type:"checkbox", width: 50 }, 
                        { field: "OrderID", headerText: "Order ID", width: 75 , textAlign: ej.TextAlign.Right}, 
                         
                             ….. 
                ] 
            }); 
        }); 
         
        function rowSelecting(args) { 
            
            if (args.target && args.target.hasClass("e-checkselectall") && args.target[0].checked == false) 
                args.cancel = true; 
        } 
         
         $(function () { 
            $(".e-checkselectall").on("click", selectall); 
        }) 
         
        function selectall(args) { 
             
            var obj = $(".e-grid").ejGrid("instance"); 
            var data = obj.model.currentViewData; 
            var pagesize = obj.model.pageSettings.pageSize; 
                obj.selectRows(0,pagesize); 
                 
                setTimeout(function () { 
                    $(".e-checkselectall")[0].checked = true; 
                }, 1); 
            } 

We have prepared a JsPlayground sample. Please refer the below link for the sample. 


Regards,
Prasanna Kumar N.S.V 
 


Loader.
Up arrow icon