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

EnablePersistence saving event handlers

Thread ID:

Created:

Updated:

Platform:

Replies:

131236 Jun 30,2017 04:41 AM UTC Jul 17,2017 12:58 PM UTC ASP.NET Web Forms 5
loading
Tags: Grid
Andrew
Asked On June 30, 2017 04:41 AM UTC

I have a grid that is setup in a RAZOR view and I want to save it's state to keep filtering intact after leaving the page. However, I noticed and interesting issue that my event handlers are being persisted so if myself or a client have used the grid before and a change is made to the event handlers the grid will fail to work as expected. I need a way to enable persistence but exclude event handlers from this persistence. As well I need a solution that can work on any grid instance as I have many grids that I want to enable persistence on.

Alan Sangeeth S [Syncfusion]
Replied On July 3, 2017 10:58 AM UTC

Hi Andrew, 

In Grid control, by default we have not included some properties while maintaining Grid State. To exclude other properties from maintaining its state use ignoreOnPersist Grid method. Please refer to the following code example. 

 
var gridObj = $("#Grid").ejGrid("instance");//get the gridObject 
 
gridObj.ignoreOnPersist(["actionBegin", "actionComplete"]);// set the properties that are to be prevented from being persisted 
 

Please refer to the following documentation links for further reference. 

Regards,
Alan Sangeeth S 


Andrew
Replied On July 5, 2017 01:42 PM UTC

Thanks Alan!

Is there a way to set those as defaults? My concern with that is if I set that after the page has loaded and the grid setup via the unobtrusive JavaScrip it will have already loaded the previous event handlers. Ideally I'd like a way to either set this via RAZOR or set the default values for this.


Renjith Singh Rajendran [Syncfusion]
Replied On July 6, 2017 12:53 PM UTC

Hi Andrew, 

We have achieved state maintenance in grid using browser local storage. When loading the grid sample at first time, there will be no event handlers in local storage and so the persistence functionality will not override the events in the grid for the very first time. So at that time in Grid “load” event, we have added the grid events to ignoreOnPersist list.  
 
Hence after refreshing the page also,  the events will not overridden from the local storage since it has been ignored.  
 
Regards, 
Renjith Singh Rajendran. 


Andrew
Replied On July 15, 2017 03:21 PM UTC

I ended up finding a solution after a lot of trial and error and by inspecting the Grid object in a debugger. As mentioned I have many grids and I didn't want to have to add a method on document load for every single one of them. I found I could modify the prototype for the Grid and add what I needed to the _ignoreOnPersist array. Doing it this way, every grid that gets created ignores the correct items by default. I don't have the code in front of me but it should be:

ej.Grid.prototype._ignoreOnPersist = ej.Grid.prototype._ignoreOnPersist.concat([/*Items that need to be ignored by default*/]);

Thavasianand Sankaranarayanan [Syncfusion]
Replied On July 17, 2017 12:58 PM UTC

Hi Andrew, 

Thanks for your update. 

You can proceed with your solution. 

If you need further assistance on this, then please get back to us.  

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.

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

;