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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Selected checkboxes in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

143569 Dec 14,2018 04:51 PM UTC Mar 27,2019 09:51 AM UTC ASP.NET Core 3
loading
Tags: Grid
Stefan
Asked On December 15, 2018 07:34 AM UTC

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

Mohammed Farook J [Syncfusion]
Replied On 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 


Guadalupe
Replied On 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


Vignesh Natarajan [Syncfusion]
Replied On 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. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;