autowidth

Hi,



I’m having trouble getting autowidth for columns to work. As you can see below, I basically want all of my columns to be automatically be the size of the content but it’s not working. It’s setting everything to a standard default size (of 50 I think).



Please help.



Thanks



===========================

mygrid = new dhtmlXGridObject(‘gridbox’);

mygrid.setImagePath(“codebase/imgs/”);

mygrid.setHeader(“Creative Schedule Name,Client,Product 1,Product 2,Product 3,Product 4,Ad-ID 1,%,Ad-ID 2,%,Ad-ID 3,%,Ad-ID 4,%,Length,Start Date,End Date,Estimate,Comment”);

mygrid.setInitWidths(",,,,,,,,,,,,,,,,,,*");

mygrid.setColAlign(“center,center,center,center,center,center,center,center,center,center,center,center,center,center,center,center,center,center,center”);

mygrid.setColTypes(“ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro”);

mygrid.setSkin(“light”);

mygrid.enableLightMouseNavigation(true);

mygrid.submitOnlyChanged(true);

mygrid.init();

mygrid.loadXML("<?= $filename ?>");//

mygrid.moveToVisible = function(cell){return true;};

mygrid.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter");

mygrid.attachEvent(“onEditCell”,function(stage,id,ind){

if (stage == 2 )

this.forEachCell(id,function(el){

el.cell.wasChanged=true;

})

return true;

});

to be automatically be the size of the content
* as size means that column takes all available space in grid, but it doesn’t mean auto-sizing by content length.

Auto-sizing by content can be achieved by

mygrid.loadXML("<?= $filename ?>",function(){
for (var i=0; i<mygrid.getColumnsNum(); i++)
mygrid.adjustColumnSize(i);

});