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. Image for the cookie policy date

How to prevent columns from persisting in ASP.NET MVC Grid


I have a grid with both .EnablePersistence() and .AllowReordering().

At some point, based on a condition in a js, I am deleting everything from localstorage, but the MVC grid still persists the columns ordering :(

Here's the JS

                var arr = []; // Array to hold the keys
                var i;

                for (i = 0; i < localStorage.length; i++) {
                    if (localStorage.key(i).substring(0, 3) === "$ej") {

                for (i = 0; i < arr.length; i++) {

1 Reply

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team July 17, 2019 06:39 AM UTC

Hi Catalin,  

Thanks for contacting Syncfusion Support. 

We could see you would like to prevent the columns from persisting in the Grid. To avoid the persistence for the Grid columns, override the addOnPersist method of the Grid and remove the columns from the key list given for persistence. In the following code example, we have overrode the addOnPersist method within the DataBound event of the Grid. 

    function onBound(args) { 
        var cloned = this.addOnPersist; 
        this.addOnPersist = function (key) { 
            key = key.filter(item => item !== "columns") 
            return cloned.call(this, key); 

Seeni Sakthi Kumar S. 

Live Chat Icon For mobile
Up arrow icon