DHTMLX Docs & Samples Explorer

Cookies Manipulation

The user should include dhtmlxgrid_ssc.js file into the HTML in order to be able to manipulate with cookies.

Enabling Automatic Saving to Cookies

The following method can be used for this purpose:

    <script>
        grid.enableAutoSizeSaving(name,cookie_param); // automatic saving of columns sizes
        grid.enableAutoHiddenColumnsSaving(name,cookie_param); // automatic saving of columns state (hidden|shown)
        grid.enableAutoSaving(name,cookie_param); // automatic saving of all possible parameters
        grid.enableOrderSaving(name,cookie_param); // automatic saving of columns order
        grid.enableSortingSaving(name,cookie_param); // automatic saving of sorting state
    </script>
 

The parameters of all the above mentioned methods are the following:

  • name - optional, cookie name;
  • cookie_param - additional parameters added to cookie.

Saving to Cookies

There are several methods in dhtmlxGrid that are responsible for saving to cookies:

    <script>
        grid.saveHiddenColumnsToCookie(name,cookie_param); // save columns state (hidden|shown) to cookies
        grid.saveOrderToCookie(name,cookie_param); // save sorting order to cookies
        grid.saveSortingToCookie(name,cookie_param); // save sorting to cookies
        grid.saveSizeToCookie(name,cookie_param); // save column width to cookies
    </script>
 

The parameters of all the above mentioned methods are the following:

  • name - optional, cookie name;
  • cookie_param - additional parameters added to cookie.

Loading from Cookies

There are also several script methods for loading from cookies:

    <script>
        grid.loadHiddenColumnsFromCookie(name); // load columns state (hidden|shown) from cookies
        grid.loadOrderFromCookie(name); // load sorting order from cookies
        grid.loadSizeFromCookie(name); // load grid layout from cookies
        grid.loadSortingFromCookie(name); // load sorting order from cookies   
    </script>
 

The parameter of all the above mentioned methods is name - optional, cookie name.

Clearing Cookies

The method responsible for clearing cookie with grid configuration details is the following:

    <script>
        grid.clearConfigCookie(name);
    </script>
 

The parameter of this method is name - optional, cookie name.