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

Columns order still persists after deleting localStorage

Thread ID:

Created:

Updated:

Platform:

Replies:

145969 Jul 16,2019 09:29 AM UTC Jul 17,2019 06:39 AM UTC ASP.NET MVC - EJ 2 1
loading
Tags: Grid
Catalin Radoi
Asked On July 16, 2019 09:29 AM UTC

Hi.

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") {
                        arr.push(localStorage.key(i));
                    }
                }

                for (i = 0; i < arr.length; i++) {
                    localStorage.removeItem(arr[i]);
                }

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On 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. 

@Html.EJS().Grid("DefaultFunctionalities").DataSource((IEnumerable<object>)ViewBag.dataSource).DataBound("onBound").AllowReordering().EnablePersistence(true) 
.AllowPaging().PageSettings(page=>page.PageCount(5)).Render() 
 
<script> 
    function onBound(args) { 
        var cloned = this.addOnPersist; 
        this.addOnPersist = function (key) { 
            key = key.filter(item => item !== "columns") 
            return cloned.call(this, key); 
        };  
    } 
</script> 

Regards,  
Seeni Sakthi Kumar 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.

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