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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get selected records from all page in multi checkbox feature?

This knowledge base explains how to get the selected Records from all the pages in grid when using checkbox selection.

We can get array of selected record index value with corresponding page information from the variable checkSelectedRowsIndexes of the Grid. Using the selected record index from that variable, we can get the selected records from model.dataSource (dataSource bound to the Grid).

The checkSelectedRowsIndexes is a collection which holds the page Index and the selected record index of the corresponding page.  

 

HTML

 

JS

 

RAZOR:

 

C#

 

ASPX

 

 

.Net Core

 

 

Angular2:

 

TypeScript:

 

We can get the selected record details in button click event after selecting all the records using checkbox selection.

Note: This will work only for the local data and not for the remote data. Since Grid will not aware of the other page records in the remote dataSource, it loads current data alone while pagination. If any other actions such as sorting, filtering, grouping has be taken place, we cannot get the selected records from the Grid dataSource.

 

TypeScript:

 

Figure: Grid with selection and selected records of all the page in console

 

Sample Demo: http://jsplayground.syncfusion.com/db0pbnak

Article ID: Published Date: Last Revised Date: Platform: Control:
7624 03/31/2017 09/12/2018 JavaScript ejGrid
Did you find this information helpful?
Comments
Sunil patra Jan 16, 2018

error :  ejGrid: methods/properties can be accessed only after plugin creation

pls help!!!

Reply
Mani Sankar Durai [Syncfusion] Jan 17, 2018

Hi Sunil,

 

We have checked your query and we suspect that the cause of the issue is that you have created a grid instance in the document ready before the Grid control get rendered. So please ensure to create an instance after grid control has rendered.

If you still face the issue please get back to us with the following details.

1.       Share the full grid code that you have used.

2.       If possible please share the sample with issue reproducing.

The provided information will help us to analyze the issue and provide you the response as early as possible

 

Regards,

Manisankar Durai.

Reply
Sunil patra Jan 18, 2018

typescript/////

ngOnInit() {
this.fetchClientList();
this.commands = [{
type: 'delete',
buttonOption: {
iconCss: ' e-icons e-delete',
cssClass: 'e-flat',
click: this.onClick
}
}];
console.log('grid object' + this.grid);
}
public onClick(this) {
console.log(this);
let grid = $('#grid').ejGrid('instance');
let index = $('#grid').element.closest('tr').index();
let record = $('#grid').getCurrentViewData()[index];
alert('Record Details: ' + JSON.stringify(record));
}


html/////
<ej-grid id='grid' [dataSource]='clientData' [allowSorting]='true' [selectionSettings]='selectOptions' (rowSelected)="onRowSelected($event)"
(dataBound)="dataBound()">
<e-columns>
<e-column field='clientName' headerText='NAME' width='150' textAlign="left">e-column>
<e-column field='companies.name' headerText='COMPANY' width='50' textAlign="left">e-column>
<e-column field='station' headerText="STATION" width='40' textAlign="left">e-column>
<e-column field='formats.length' headerText='FORMAT' width='20' textAlign="right">e-column>
<e-column headerText='Manage Records' width='40' [commands]='commands'>e-column>
e-columns>
ej-grid>

Reply
Sunil patra Jan 18, 2018

this produces the above issue


Mani Sankar Durai [Syncfusion] Jan 18, 2018

Hi Sunil,

 

We have checked the reported issue with the provided code example and we are not able to reproduce the reported issue.

We have also prepared a sample based on the provided code example and that can be available from the below link

Link: http://www.syncfusion.com/downloads/support/directtrac/196682/ze/angular2-seeds-systemjs508964927

We have also found that you have called getCurrentViewData() using grid element instead of getting from grid instance. We suggest you to modify the code as like below

 

public onClick(e: any) {

        console.log(e);

        var grid = $('#grid').ejGrid('instance');

        var index = grid.getSelectedRows().closest("tr").index()

        var record = grid.getCurrentViewData()[index];

        alert('Record Details: ' + JSON.stringify(record));

    }

 

Also we found that you are trying to get the selectedRecords in grid. To get the selected records we suggest you to use getSelectedRecords method in grid.

Link: https://help.syncfusion.com/api/angular/ejgrid#methods:getselectedrecords

If you still face the issue please provide the sample with issue reproducing.

 

Regards,

Manisankar Durai.

Reply
Sunil patra Jan 19, 2018

after implementing ur code , i still got the error :  ejGrid: methods/properties can be accessed only after plugin creation

Mani Sankar Durai [Syncfusion] Jan 19, 2018

Hi Sunil

 

Before proceeding please provide us the following details.

1.      Share the video demonstration of the reported issue that you have faced.

2.      Share the stack trace of the issue from the console window.

3.      You have called a method fetchClientList in ngOnInit. Share the code that you have used in fetchClientList method.

4.      Share the sample with issue reproducing.

The provided information will help us to analyze the issue and provide you the response as early as possible

 

Regards,

Manisankar Durai.

Reply
Add Comment
You must log in to leave a comment

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