Persisted Grid is firing rowSelected after clicking back button

I am using the rowSelected to navigate to a new window.location. I have the enablePersistence="true" and I also have 

<e-grid-selectionSettings persistSelection="false"></e-grid-selectionSettings>


When hitting the back button to return to the grid the rowSelected is firing.  I need the rowSelected to be cleared.  Is there a way to achieve this.


Thanks


1 Reply

JC Joseph Christ Nithin Issack Syncfusion Team January 28, 2022 05:49 PM UTC

Hi Dan, 

  Greetings from Syncfusion support. 

  Based on your requirement, you are having a grid with persistence enabled, and on rowSelected event you navigate to a new page. When you click on the back button you return to the previous page and the grid is refreshed and the rowSelected event is triggered automatically. This is because, since you have enabled persistence, the selectedRowIndex is stored in the persisted data. When the grid is refreshed the row gets selected automatically and the rowSelected event is triggered.  

  We have achieved your requirement by overriding an internal function `addOnPersist` method and removed the `selectedRowIndex` from the persisted items in the `dataBound` event of the EJ2 Grid. 


function dataBound(args) { 
            var cloned = this.addOnPersist; 
            this.addOnPersist = function (key) { 
                key = key.filter(item => item !== 'selectedRowIndex'); 
                return cloned.call(this, key); 
            }; 
        } 

 

Please get back to us for further details. 

Regards, 
Joseph I. 


Loader.
Up arrow icon