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

Selected checkboxes in grid

Hi

EJ2.Grid in ASP.Net Core with checkboxes, see attached image. How do I client side get selected rows (checked rows)?

/S



Attachment: Syncfusion_296f88bd.zip

3 Replies

MF Mohammed Farook J Syncfusion Team December 17, 2018 09:05 AM UTC

Hi Stefan, 
 
Thanks for contacting Syncfusion support. 
 
 
We have validated your requirement  and we can get the selected rows by using ‘gridObj.getSelectedRows()’ method of Grid and also we can get the selected records by using ‘gridObj.getSelectedRecords()’  method of Grid. Please find the screenshot and documentation for your reference. 
 
 
 
 
Documentation :  
 
 
 
 
 
 
Regards, 
J Mohammed Farook 



GU Guadalupe replied to Mohammed Farook J March 26, 2019 09:32 PM UTC

Hi Stefan, 
 
Thanks for contacting Syncfusion support. 
 
 
We have validated your requirement  and we can get the selected rows by using ‘gridObj.getSelectedRows()’ method of Grid and also we can get the selected records by using ‘gridObj.getSelectedRecords()’  method of Grid. Please find the screenshot and documentation for your reference. 
 
 
 
 
Documentation :  
 
 
 
 
 
 
Regards, 
J Mohammed Farook 


Hello

I am work with this. I need print a selection of elements with checkbox.
Your can help me?


Cordially, Guadalupe Baigorria



VN Vignesh Natarajan Syncfusion Team March 27, 2019 09:51 AM UTC

Hi Guadalupe, 
 
Thanks for using Syncfusion products. 
 
Query#:- I need print a selection of elements with checkbox. 
 
We have analyzed your query and we can print the records selected using checkbox using BeforePrint event of ejGrid. In the ActionBegin event, we have collected the selected rows and also while on navigating the pages. The selected records will be saved to window variable and later in the BeforePrint event of the Grid, it has been used for printing the Grid.  
 
 
Please refer to the code example:- 
 
<ej:Grid ID="FlatGrid" runat="server" AllowPaging="true" > 
     <ToolbarSettings ShowToolbar="true" ToolbarItems="printGrid"></ToolbarSettings> 
         <Columns> 
             <ej:Column Type="checkbox" Width="50"></ej:Column> 
            <ej:Column Field="OrderID" HeaderText="Id" IsPrimaryKey="true" Width="20" TextAlign="Left" HeaderTextAlign="center"  /> 
                .   .     . 
        </Columns> 
     <ClientSideEvents ActionComplete="oncomplete" BeforePrint="beforePrint" ActionBegin="actionbegin"/>  
     </ej:Grid> 
    </div> 
    <script type="text/javascript"> 
         window.selectedRows = []; 
              function printSelectedRows(selRows) { 
                  if (!selectedRows.length) 
                      selectedRows = selRows; 
                  else { 
                    for (var sr = 0; sr < selRows.length; sr++) { 
                    selectedRows.push(selRows[sr]); 
                  } 
                } 
              } 
               function beforePrint(args) { 
                    var gridInst = $("#MainContent_FlatGrid").ejGrid("instance"); 
                    var selRows = gridInst.getContentTable().find('tr[aria-selected="true"]'); 
                    if (selectedRows.length || selRows.length) { 
                        if (selRows.length) printSelectedRows(selRows); 
                        args.element.find(".e-gridcontent tbody tr").remove(); 
                        args.element.find(".e-gridcontent tbody").append(selectedRows); 
                        gridInst.refreshContent(); 
                    } 
                } 
                 
                function actionbegin(args) { 
                    if (args.requestType == "paging") { 
                        if (this.getSelectedRows().length) { 
                            var selRows = this.getSelectedRows(); 
                            printSelectedRows(selRows); 
                        } 
                    } 
                } 
               function oncomplete(args){ 
                 if(args.requestType == "print"){   
                       window.selectedRows = []; 
                 } 
            } 
        </script> 
 
In your given screenshot, records are not selected while on checkbox is ticked. We suspect that you have enabled field property for the checkbox column. So the record has not been selected. So kindly share the Grid rendering code if you facing any issues with provided solution. 
 
Refer our API documentation for your reference 
 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon