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

Persist selection and the GridComponent

Thread ID:

Created:

Updated:

Platform:

Replies:

145181 Jun 11,2019 01:48 PM UTC Jun 14,2019 03:35 PM UTC ReactJS 3
loading
Tags: ejGrid
Niklas Sturfelt
Asked On June 11, 2019 01:48 PM UTC

Hi,

We are using the GridComponent.

When we replace the data source we want to be able to keep the selection state.
We have enabled persistSelection and set column[0] to primaryKey.
 
When the data source is replaced after an update, nothing or everything is selected in the GridComponent.

Is there an event or some other way to eneable for the selection to be persistant when the data source replaced.
We have single selection.

BR
Niklas Sturfelt
Geometra Software AB


Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On June 12, 2019 05:20 PM UTC

Hi Niklas, 

Thanks for contacting Syncfusion Support. 

Query#:- Is there an event or some other way to enable for the selection to be persistant when the data source replaced. 

We have checked your query and to achieve your requirement we need to get the selected row index using rowSelected event of the Grid. In the rowSelected event of the Grid, we can get the index and while updating the dataSource we need to update the index through selectRows method of the Grid. 
Please refer to the code example:- 

var index; 
      $(function () { 
             $("#Grid").ejGrid({ 
                    dataSource: Data, 
                    allowPaging: true, 
                    commonWidth: 200, 
                    enablePersistence: true, 
                    rowSelected: "rowSelected", 
                    actionComplete: "complete", 
 
                     
                    columns: [ 
                        { field: "OrderID", isPrimaryKey: true, headerText: "Order ID", textAlign: ej.TextAlign.Right, validationRules: { required: true, number: true } }, 
                        { field: "CustomerID", headerText: 'Customer ID', validationRules: { required: true, minlength: 3 } }, 
 
                    ] 
                }); 
            }); 
 
            function rowSelected(args) { 
                index = args.rowIndex; 
              } 
 
            function refreshData(){ 
            var gridObj = $("#Grid").ejGrid("instance"); 
            gridObj.dataSource(window.gridData); 
            gridObj.selectRows(index); 
        } 

Refer to the API Link:- 

Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 
 


Niklas Sturfelt
Replied On June 13, 2019 12:18 PM UTC

Hi again,

I have tried what you have suggested and I seem to be able to keep the selection in the grid.

The problem is however, that it does not seem possible to hinder the rowSelected event from being triggered 
when the selectRows call is made in the actionComplete callback.

Is there a way to temporarily disable the rowSelected event when a selectRows call is made?

BR
Niklas Sturfelt
Geometra Software AB

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On June 14, 2019 03:35 PM UTC

Hi Niklas, 

Query#:I s there a way to temporarily disable the rowSelected event when a selectRows call is made? 
 
We have checked your query and while using selectRows method or while selecting the records, rowSelected event gets triggered by default. As this was default behavior we cannot prevent the event. Could you please let us know for which purpose you need to prevent the event? 
 
Based on your requirement, we can disable and provide you solution. 
 
Regards, 
Farveen sulthana T 


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

Live Chat Icon For mobile
Live Chat Icon