The library provides a number of methods to manipulate cookies. Methods can take the following parameters:
The stated functionality requires PRO version of the dhtmlxGrid (or DHTMLX Suite) package.
Using cookies
mygrid = new dhtmlXGridObject('gridbox'); mygrid.enableAutoSaving("some_name","expires=Fri, 31-Dec-2010 23:59:59 GMT");
| Method | Description |
|---|---|
| Automatic saving to cookie | |
| enableAutoSaving(name,param) | enables automatic saving of the columns order (an array of ids), size and sorting type |
| enableAutoHiddenColumnsSaving(name,param) | enables automatic saving of the columns states (hidden/shown) |
| enableAutoSizeSaving(name,param) | enables automatic saving of the columns sizes |
| enableOrderSaving(name,param) | enables automatic saving of the columns order (an array of ids) |
| enableSortingSaving(name,param) | enables automatic saving of the columns sorting types |
| Manual saving to cookie | |
| saveHiddenColumnsToCookie(name,param) | saves the columns states (hidden/shown) |
| saveOrderToCookie(name, param) | saves the columns order (an array of ids) |
| saveSortingToCookie(name,param) | saves the columns sorting types |
| saveSizeToCookie(name,param) | saves the columns sizes |
| Loading from cookies | |
| loadHiddenColumnsFromCookie(name) | loads the columns states (hidden/shown) from cookie |
| loadOrderFromCookie(name) | loads the columns order (an array of ids) from cookie |
| loadSizeFromCookie(name) | loads the columns sizes from cookie |
| loadSortingFromCookie(name) | loads the columns sorting types from cookie |
| Clearing cookies | |
| clearConfigCookie(name) | clears the specified cookie |
While using automatic saving remember the following rules:
Automatic saving to cookie. The order of calling the related methods
mygrid = new dhtmlXGridObject('gridbox'); ... mygrid.init(); // firstly, initialize the grid mygrid.loadOrderFromCookie(); // then restore the required data mygrid.loadSizeFromCookie(); mygrid.loadSortingFromCookie(); mygrid.loadHiddenColumnsFromCookie(); mygrid.enableAutoSizeSaving(); // enable saving cookies mygrid.enableSortingSaving(); mygrid.enableOrderSaving(); mygrid.enableAutoHiddenColumnsSaving(); mygrid.load("data.php"); // load data to the grid
Related sample: Saving/restoring columns' states
Back to top