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.

How to get all selected records from a table

Thread ID:

Created:

Updated:

Platform:

Replies:

130248 May 2,2017 06:54 AM May 3,2017 12:07 PM JavaScript 1
loading
Tags: ejGrid
Daniel Pujante
Asked On May 2, 2017 06:54 AM

Hi,

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");
                selectedRecords=datosGrid.model.selectedRecords;

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

Thank you very much

Regards,

Daniel Pujante




Thavasianand Sankaranarayanan [Syncfusion]
Replied On May 3, 2017 12:07 PM

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."> 
        <button>click</button> 
    </a> 
 
    <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> 
 
                        ------------                          
 
                    </div> 
                </div> 
            </div> 
 
        </div> 
    </div> 
    <script> 
        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])) 
                        continue; 
                    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. 
 
                        } 
                    } 
 
                } 
            } 
        }); 
    </script> 
</body> 

We have prepared a sample in the JsPlayground 


Regards, 
Thavasianand S. 


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.

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.

;