column width is not restored [solved]

Hi,
I solved the Problem with the cookie, so that the columns order and columns width is restored after restarting the browser.
Now I have got the problem, that I drop the last column at the second position and resize it.

After restarting the browser the order of columns is correct, but the width is not correct.

Here are some line:

var mygrid = new dhtmlXGridObject('div_liste');
mygrid.setImagePath("./imgs/");

datum = new Date();
datum.setDate(datum.getDate()+60);

mygrid.enableAutoSizeSaving('liste','expires='+datum.toGMTString());
mygrid.enableOrderSaving('liste','expires='+datum.toGMTString());


mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.enableMultiselect(false);

mygrid.attachEvent("onRowSelect", rowSelected);
mygrid.attachEvent("onRightClick", function(id,ind,obj){return;});
mygrid.attachEvent("onEditCell", function(stage,rId,cInd,nValue,oValue){return false;});
mygrid.enableColumnMove(true);

function rowSelected(id,ind) {
	target = mygrid.getRowAttribute(id,"target");
	selectorder(id,target);
}


mygrid.loadXML("./xml.php", function() {
	updateInfo();
    mygrid.loadSizeFromCookie('liste');
	mygrid.loadOrderFromCookie('liste');
});

maybe someone can help me this time.
hibbert

push :frowning:

Issue confirmed and will be fixed at the next version of dhtmlxGrid

ok, tahnk you.

I have found a solution that works for me. I save my own cookie and read it in the php file which creates the xml document for the grid.

To fix the original issue, try to replace order of commands as

[code]mygrid.loadXML("./xml.php", function() {
updateInfo();
mygrid.loadOrderFromCookie(‘liste’);
mygrid.loadSizeFromCookie(‘liste’);

  mygrid.enableAutoSizeSaving('liste','expires='+datum.toGMTString());
  mygrid.enableOrderSaving('liste','expires='+datum.toGMTString());

});[/code]

a) order restored before restoring column sizes
b) saving command called only after loading one ( which will prevent value overwriting )

I have the same problem, but I also use hidden columns…

I call this function after loadXML finshed function…

[code]
function startCookies() {
var dashBoard = null;
switch (readCookie(“txBoard”)) {
case “0”:
dashBoard = “ATISopenTxState”;
break;
case “4”:
dashBoard = “ATISallTxState”;
break;
case “8”:
dashBoard = “ATISeditTxState”;
break;
default:
dashBoard = “”;
break;
}

//alert(readCookie("gridSettings"+dashBoard));

myTxGrid.loadOrderFromCookie(dashBoard);
myTxGrid.loadSortingFromCookie(dashBoard);
myTxGrid.loadSizeFromCookie(dashBoard);
myTxGrid.loadHiddenColumnsFromCookie(dashBoard);

myTxGrid.enableAutoSizeSaving(dashBoardType, "expires="+expires.toGMTString()+";");
myTxGrid.enableSortingSaving(dashBoardType, "expires="+expires.toGMTString()+";");
myTxGrid.enableOrderSaving(dashBoardType, "expires="+expires.toGMTString()+";");
myTxGrid.enableAutoHiddenColumnsSaving(dashBoardType,"expires="+expires.toGMTString()+";");

}[/code]

For everyone who needs help for that:

I solved this by myself! :slight_smile:

If you attach events “onResizeEnd”, “onColmnHidden”, “onAfterCMove”, “onAfterSorting” to your Grid, before loading size / hidden columns / order / sorting the function calls loadXyzFromCookie are interpreted as onXyzEvent …

So if I say “loadOrderFromCookie”, it saves “onAfterCMove” the sizes of my current grid to my cookie, and “loadSizeFromCookie” does affect in “nothing” because the data gets overwritten!

So add the named events after loading the data from your cookie, and everything will be fine!

Maybe you can add some changes for that in some future releases, not to call the events on calling the loadXyzFromCookie methods!

Kind regards!