Saving/restoring columns' states
Try to sort, move columns or change their width and then reload page. Grid's API allows to restore these states automatically or on demand *
|
|||||||||
Automatically Save/Restore columns' states |
* - cookies must be enabled
</> Source
<!DOCTYPE html>
<!--pro-->
<html>
<head>
<title>Saving/restoring columns' states</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<script>
var myGrid, myGrid2;
function doOnLoad(){
myGrid = new dhtmlXGridObject('gridbox');
myGrid.setImagePath("../../../codebase/imgs/");
myGrid.enableColumnMove(true);
myGrid.enableAutoWidth(true);
myGrid.enableAutoHeight(true);
myGrid.load("../common/gridH.xml");
myGrid2 = new dhtmlXGridObject('gridbox2');
myGrid2.setImagePath("../../../codebase/imgs/");
myGrid2.enableColumnMove(true);
myGrid2.enableAutoWidth(true);
myGrid2.enableAutoHeight(true);
myGrid2.load("../common/gridH.xml",function(){
myGrid2.loadOrderFromCookie();
myGrid2.loadSortingFromCookie();
myGrid2.loadSizeFromCookie();
myGrid2.enableAutoSizeSaving();
myGrid2.enableSortingSaving();
myGrid2.enableOrderSaving();
});
}
</script>
</head>
<body onload="doOnLoad()">
<h1>Saving\restoring columns' states</h1>
<p>Try to sort, move columns or change their width and then reload page. Grid's API allows to restore these states automatically or on demand *</p>
<table width="800" cellpadding="0" cellspacing="0">
<tr>
<td>
<div id="gridbox" style="width:100%;height:350px;background-color:white;"></div>
<div align="center">
<table cellspacing="3" cellpadding="0" border="0">
<tr><td align="right"> <input type="button" name="a1" value="save columns width" onclick="myGrid.saveSizeToCookie()"></td><td width="5" rowspan="3"></td><td bgcolor="black" rowspan="3" width="1"></td><td width="5" rowspan="3"></td><td><input type="button" name="a1" value="restore columns width" onclick="myGrid.loadSizeFromCookie()"></td></tr>
<tr><td align="right"><input type="button" name="a1" value="save sorting" onclick="myGrid.saveSortingToCookie()"></td><td><input type="button" name="a1" value="restore sorting" onclick="myGrid.loadSortingFromCookie()"></td></tr>
<tr><td align="right"><input type="button" name="a1" value="save order" onclick="myGrid.saveOrderToCookie()"></td><td><input type="button" name="a1" value="restore order" onclick="myGrid.loadOrderFromCookie()"></td></tr>
</table>
</div>
</td>
</tr>
<tr>
<td>
<p>Automatically Save/Restore columns' states</p>
<div id="gridbox2" style="width:100%;height:350px;background-color:white;"></div>
</td>
</tr>
</table>
<br>
* - cookies must be enabled
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.