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

How to get all selected records from a table


I have a table with 200 records with 'allowPaging: true', and added a checkbox column. When I select the header column's checkbox, it is supposed to be selected all records (200).In fact, I can see selected all of them when I change of page. However, when I set 'selectedRecords' as you can see below (I'm using 'Angular'), it just contains the records yor are seeing on the table's page (10 o 11 ) although all the table's records are selected (200).

var datosGrid = angular.element("#gridConsulta").data("ejGrid");

Could you help me about how I could set 'selectedRecords' the all selected records of the table.

Thank you very much


Daniel Pujante

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team May 3, 2017 04:07 PM UTC

Hi Daniel, 

Thanks for contacting Syncfusion support. 

Query: Get all the selected rows across all pages. 
We have analyzed your query and we suspect that you want to get all the selected record across all the pages. But in our getSelectedRecords() method, we have only get selected record from the current page this is the behavior of ejGrid. 

We have achieved your requirement using the below work around. So, please refer the below code example. 

<body ng-controller="PhoneListCtrl"> 
    <a rel='nofollow' href="#" ng-click="clik()" title="View the uploaded rate data."> 
    <div class="content-container-fluid"> 
        <div class="row"> 
            <div class="cols-sample-area"> 
                <div id="Grid" ej-grid e-datasource="data" e-allowpaging="true"> 
                    <div e-columns> 
                        <div e-column e-type="checkbox"></div> 
        var obj = [ 
        angular.module('listCtrl', ['ejangular']) 
        .controller('PhoneListCtrl', function ($scope) { 
            $scope.data = obj; 
            $scope.clik = function () { 
                var gridObj = $("#Grid").ejGrid('instance'); 
                var selectedrecordIndex = gridObj.checkSelectedRowsIndexes; //Get the selected row index across all page wise 
                var selectedRecord = []; 
                for (var i = 0; i < selectedrecordIndex.length ; i++) { 
                    if (ej.isNullOrUndefined(selectedrecordIndex[i])) 
                    else { 
                        for (var j = 0; j < selectedrecordIndex[i].length; j++) { 
                            var index = selectedrecordIndex[i][j] + (i * gridObj.model.pageSettings.pageSize);  //Calculate the index for retrieve those data in the data source 
                            selectedRecord.push(gridObj.model.dataSource[index]); // push the selected record from the data source. 

We have prepared a sample in the JsPlayground 

Thavasianand S. 

Live Chat Icon For mobile
Up arrow icon