How to make Auto column resizing and auto save cookie if table init from html ?
|
How to make Auto column resizing and auto save cookie if table init from html ?
|
It works nearly the same as in case of normal initialization
window.onload = new function(){
var mygrid = dhtmlXGridFromTable(‘tblToGrid’);
mygrid.loadSizeFromCookie(); // load previously save sizes
mygrid.enableAutoSizeSaving(); // enable size saving after each column resize
}
And what to make Auto column resizing and paginal output from html table ???
The API is the same as in case of normal loading
var mygrid = dhtmlXGridFromTable(‘tblToGrid’);
mygrid.enablePaging(…
for (var i=0; i<mygrid.getColumnCount(); i++)
mygrid.adjustColumnSize(i);
In case of html initialization it is necessary to use cookie name. So, please, try to use the following:
var mygrid = dhtmlXGridFromTable(‘tblToGrid’);
mygrid.loadSizeFromCookie(“sizes”);
mygrid.enableAutoSizeSaving(“sizes”);
cookie do not work.
More low I result a code
Where an problem?
---------------------------------
| Column 1 | Column 2 |
| value 11 | value 12 |
| value 21 | value 22 |
| value 31 | value 32 |
| value 41 | value 42 |
| value 51 | value 52 |
Try to remove “new” from onload event handler.
The following should work correctly:
window.onload = function(){
var mygrid = dhtmlXGridFromTable(‘tblToGrid’);
for (var i=0; i<mygrid.getColumnCount(); i++)
mygrid.adjustColumnSize(i);
mygrid.loadSizeFromCookie(“sizesx”);
mygrid.enableAutoSizeSaving(“sizesx”);
}
You missed quotes around sizes
orders_table.loadSizeFromCookie(“sizes”); // <- missed quotes
orders_table.enableAutoSizeSaving(“sizes”);