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

Multiselect grid - keep selected rows after sorting

Thread ID:





126413 Oct 14,2016 08:51 AM UTC Oct 17,2016 12:19 PM UTC JavaScript 1
Tags: ejGrid
Stefano Enrico
Asked On October 14, 2016 08:51 AM UTC

i have a multiselect grid with virtual scrolling and offline = true.
Is possible to keep the slected rows after sorting?



Venkatesh Ayothi Raman [Syncfusion]
Replied On October 17, 2016 12:19 PM UTC

Hi Stefano, 

Thank you for contacting Syncfusion support. 

The selected records are doesn’t maintain when we sorting the Grid. Because while sorting the data we have refresh the whole Grid content. So select records are also cleared. We have achieved your requirement by using actionComplete and actionBegin event in Grid. Please refer to the code example, sample and Help document, 
Code example: 
$(function () { 
            window.baseurl = "http://js.syncfusion.com/demos/ejservices/"; 
            var dataManger = ej.DataManager({ 
                url: window.baseurl + "wcf/Grid/GridService.svc/Orders", crossDomain: true, offline: true, 
                dataSource: dataManger, 
                offline: true, 
                allowScrolling: true, 
                scrollSettings: { 
                    allowVirtualScrolling: false, 
                    virtualScrollMode: ej.Grid.VirtualScrollMode.Normal, 
                    height: 400, 
                    //width: 600, 
                    scrollOneStepBy: 33, 
                    enableTouchScroll: false 
                allowFiltering: true, 
                filterSettings: { filterType: 'excel', enableComplexBlankFilter: false, blankValue: '' }, 
                . . . 
                columns: [ 
. . . 
. . . 
        //actionComplete event 
        function actionComplete(args) { 
            if (args.requestType == "sorting" || args.requestType == "virtualscroll") { // Check the condition 
                var data = this.model.currentViewData, len = this.model.currentViewData.length, arrayLength = primaryKeyValuesArray.length; 
                for (j = 0; j < len; j++) { 
                    for (k = 0; k < arrayLength; k++) { 
                        var value = data[j]["OrderID"]; //Get the value of primary key when we virtual scrolling 
                        if (value == primaryKeyValuesArray[k]) { // Check the stored records primary key values and currnet view data primary key value 
                            this.multiSelectCtrlRequest = true; 
                            this.selectRows(j); //Select the row using selectRows method 
                            this.getSelectedRows().find("input").attr('checked', true); // Check the checkbox for selected records 
        //actionBegin event 
        function actionBegin(args) { 
            if (args.requestType == "sorting") {// Check the condition 
                var selectedRecords = this.getSelectedRecords(), length = this.getSelectedRecords().length; //Get the currently selectedRecords and length using getSelectRecords method. 
                primaryKeyValuesArray = []; // Create a gloabl array for future use 
                for (i = 0; i < length; i++) { 
                    var value = selectedRecords[i]["OrderID"] 
                    primaryKeyValuesArray.push(value); //Push the primary key values of currently selected records 

Help documents: 


Venkatesh Ayothiraman. 


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