grid autowidth - dynamic

Hello,

I wish to let the user choose the grid autowidth property by way of a checkbox.

What I have works by dynamically resizing the window but it seems to be a bad approach, and does not work if the browser is maximized.

What is the right way to toggle modes dynamically?

Thank you,

Mike

<head>
<title>sample</title>
<div id="gridbox" width="100%" height="100%" style="background-color:white; overflow:hidden"></div>
<div id="paging"></div>
<div id="data" style="font-size:smaller; font-family:tahoma">Loading...</div>
<script type="text/javascript">
	mygrid = new dhtmlXGridObject('gridbox');
	mygrid.setImagePath("codebase/imgs/");
	mygrid.setHeader("Last Name,Email");
	mygrid.attachHeader("#connector_text_filter,#connector_text_filter");
	mygrid.setInitWidths("180,100");
	mygrid.setColTypes("ro,link");
	mygrid.setColSorting(connector,connector");
	mygrid.enablePaging(true, 20, 3, 'paging', true);
	mygrid.setPagingSkin("toolbar", "dhx_skyblue");
	mygrid.enableAutoHeight(true);
	mygrid.enableAutoWidth(true);
	mygrid.enableColumnMove(true);
	mygrid.enableMultiselect(true);
	mygrid.attachEvent("onXLS", function () { 
                             document.getElementById("data").style.display = "block"; });
	mygrid.attachEvent("onXLE", function () { 
                               document.getElementById("data").style.display = "none"; });
	mygrid.init();
	mygrid.loadXML("inall/");
	var dp = new dataProcessor("inall");
	dp.init(mygrid);
	function setAutoWidth() {
		var bSetting = chkautowidth.checked;
		mygrid.enableAutoWidth(bSetting);
		window.resizeBy(-1, 0);
	}
</script>
</head>

Unfortunately there is no way to toggle auto width mode in grid dynamically. You should completely destroy grid object with destruct method and initialize it again.