AutoFit Column width

Hi,

I’m having some problems with auto fitting of the columns of the grid.

I’m making use of the function to autofit the column according to the contents in the grid.



Response.Write “function onLoadingEndFunc(){” & vbCrLf

Response.Write "    var count = grid.getColumnCount();" & vbCrLf

Response.Write "        for(var i = 0; i < count; i++)" & vbCrLf

Response.Write "            grid.adjustColumnSize(i);" & vbCrLf

Response.Write "    }" & vbCrLf



I’m calling the function while loading the grid.



Response.Write sGridObjName & “.loadXMLString(sXML, onLoadingEndFunc);” & vbCrLf



This works fine until i dont have to save the column widths.

But,

when i modify the column size and set the column value and then when i open the same grid i’m unable to get the set value of the column size. I’m also making use of onResizeEnd function to get the resized values of the column.



Is there a way by which i can get the grid with autofitting values when there are no set values and the auto fitting should be turned off when the column size is set manually?

You can try use code similar to next

var width = grid._getCookie(name,1); //return not null value if size was saved to cookie previously
if (width)
grid.loadSizeFromCookie(name);
else
for(var i = 0; i < count; i++)
grid.adjustColumnSize(i);