Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Larry on Feb 17, 2009 19:25
open dhtmlx forum
first click makes subrow height too large, close click, then click again and row height is proper

Hi, I'm struggling with this issue:

I'm using a subgrid.

Upon the initial load of the page, I click the "+" to open the sub grid. The row on the main grid expands, but it's height is WAY to large. I click the "-" to close the expanded row, then click the "+" again and this time, the row expansion is correct....... it takes the height of the internal subgrid.

Here's two pics to show what I'm talking about:
http://picasaweb.google.com/LarryAtCLT/FirstClickMakesSubrowHeightTooLargeCloseClickThenClickAgainAndRowHeightIsProper?feat=directlink

Here's my code:

<script>
var mygrid;
function doInitGrid(){
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("/codebase/imgs/");
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("codebase/imgs/");
mygrid.setHeader(",ID,Date,CLT#,Type,You,Status,Price,CS,EOL");
mygrid.setInitWidths("25,30,140,75,70,100,80,80,80,50");
mygrid.setColAlign("left,left,left,left,left,left,left,right,right,right");
mygrid.setColTypes("sub_row_grid,ro,ro,link,ro,ro,ro,ro,ro,ro");
mygrid.setSkin("modern");
mygrid.enableAutoHeight(true);
mygrid.init();
mygrid.parse(document.getElementById("xmlDataIsland"));

mygrid.attachEvent("onSubGridCreated",function(subgrid,id,index,data){ //data - data from related XML cell
subgrid.setHeader("A,B,C");
subgrid.setColTypes("ro,ro,ro");
subgrid.setInitWidths("100,100,100")
subgrid.enableAutoHeight(true);
subgrid.init();
subgrid.parse(document.getElementById("xmlDataIsland2"));
subgrid.callEvent("onGridReconstructed",[]);

return false;//block default logic
});
}
</script>
Answer posted by Support on Feb 18, 2009 05:48
It somehow caused by sync. way of data loading. Probably browser has not time to update sizes before onGridReconstructed event called.
You can try to update the code as

subgrid.parse(document.getElementById("xmlDataIsland2")); 
window.setTimeout(function(){
         subgrid.callEvent("onGridReconstructed",[]);
},1);

It may resolve issue. 

Also problem can be caused if you are loading some images in subgrid with height greater than normal height of row ( images are dynamic elements, and their final size will be available only when they fully loaded )