Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
500
Saving the settings of Grid on per user basis in the database
posted

Hi Team,

I am trying to save the settings (sorting,grouping,filtering,paging, width, column order, column visible) of the Hierarchical Grid on per user basis.

I am creating the grid in the controller using GridModel class and passing the same to the view.

What I understand is I will have to save the individual settings in cookie as below:

document.cookie = "columnSetting=;expires=Thu, 01 Jan 1970 00:00:01 GMT;";


var persistSorting = $("#grid11").igGridSorting("option", "columnSettings");
document.cookie = "sortingsetting" + "=" + persistSorting;

var columnSetting = $("#grid11").igGrid("option", "columns");
document.cookie = "columnSetting=" + columnSetting + ";";

var persistFiltering = $("#grid11").igGridFiltering("option", "columnSettings");

document.cookie = "filteringSetting=" + persistFiltering + ";";

//.....

//.....

Is there any other simpler way using which I can save all these and other settings in the database so that when the user logs in again, I can show a personalized grid to the user.

Also, how to bind these settings again to the Hierarchical Grid so that the Grid has the saved structure and data given that I am creating the grid,features,columns using GridModel class in the controller.

-Regards,

Agraj

Parents
  • 18204
    Offline posted

    Hello Agraj,

    Thank you for posting in our forums!

    First, I would recommend using the events for the igGrid's features to store the user's settings.  This can be done in events like dataFiltered, columnSorted, and pageIndexChanged events, to name a few.

    The arguments in these events provide the information needed that can be saved and restored.

    As for restoring these settings, if you want to save the user's settings on the server, you would need to send their settings to the server and then apply the settings while setting up your GridModel.  Saving the settings on the client with a cookie, or localStorage is simpler.  This would require using javascript to save and restore the settings.

    Similar to saving the settings in the features' events, you can use their own methods to restore the settings.  The filter, sortColumn, and pageIndex methods/options can be used for this for example.  You would need to apply these after the grid is instantiated on the page.

    I have attached to this update a simple sample demonstrating saving and restoring the sorting, filtering and paging settings on the client side using localStorage.

    If you want to save the settings on the server, you can parse the information when the user loads the page while you are setting up your GridModel and apply the settings to the features.  Some functionality may need to still be handled on client side, which is why I recommend the former approach.

    If you need any further assistance with this, please let me know and I will be glad to help.

    igGridStoreUserSettings.zip
Reply Children