onload="doInitGrid() - additional code not working

Hi

Can anyone help as to why the last bit of this (the loop) where it populates cell 7 with ‘12’ is not working?

	function doInitGrid(){
 		mygrid = new dhtmlXGridObject('mygrid_container');
		mygrid.setImagePath("codebase/imgs/");
		mygrid.setHeader("Product,Description,Usage,3 Mths,6 Mths,9 Mths,12 Mths,Sel");
		mygrid.attachHeader("#text_filter,#text_filter,#select_filter,<button onclick='doOnApplySelected(head3)'>Apply to all</button>,<button onclick='doOnApplySelected(head6)'>Apply to all</button>,<button onclick='doOnApplySelected(head9)'>Apply to all</button>,<button onclick='doOnApplySelected(head12)'>Apply to all</button>,#select_filter");
	//	mygrid.attachFooter("A,B,C,D,E,F,G");
		mygrid.setInitWidths("70,190,100,70,70,70,70,40");  
		mygrid.setColAlign("left,left,left,right,right,right,right,right");
		mygrid.setSkin("light");
		mygrid.setColSorting("str,str,str,na,na,na,na,int");
		mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro");
		mygrid.attachEvent("onRowSelect",doOnRowSelected);
		mygrid.init(); 
		mygrid.loadXML("step3.xml");
		
    	for (var l=0; l < mygrid.getRowsNum(); l++){
      		var currentrow2 = mygrid.getRowId(l);
      		mygrid.cells(currentrow2,7).setValue("12");
      	} 	      		

	}

I’ve tried putting the same loop code within an onclick function and it works ok, but any code you put after loadXML seems to be ignored. I’ve even tried a simple alert box in the same place and not even that works?

Thanks in advance

Paul

Please, try to call your additional code after the data is loaded to the grid using onXLE event or a callback function of the load() method.
For example:

mygrid.loadXML("step3.xml", function(){ for (var l=0; l < mygrid.getRowsNum(); l++){ var currentrow2 = mygrid.getRowId(l); mygrid.cells(currentrow2,7).setValue("12"); } });