Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tam Le on Aug 27, 2008 01:41
open dhtmlx forum
There are blank space at the bottom of the subgrid when it is shown on the screen

Hi,

I have created the sub grid of a grid by using the code below:

<script>
mygrid = new dhtmlXGridObject('gridbox2');
........
mygrid.attachEvent("onSubGridCreated", initSubGrids);

function initSubGrids(sgrid){
     ....................
     sgrid.loadXML("sub_data.xml");
     sgrid.attachEvent("onEditCell",doOnCellEdit);
     sgrid.attachEvent("onCheck", updateProductGroup);
     ....................
   
}
</script>

Thus, I am able to handle the events in the sub grid and it worked as expected. However, I met one problem is that when expand the row of main grid to see the data of subgrid, there are always a blank space at the bottom of the displayed subgrid. The error just happened at the first time of viewing the subgrid. If you collapse and expand the sub grid again it would be fine.

It would be a great help if you tell me how to resolve it.

Thanks & Regards,
Tam Le

Answer posted by Support on Aug 27, 2008 02:30
Add next code to the subgrid creation

function initSubGrids(sgrid){
  ....................
  sgrid.loadXML("sub_data.xml",function(){
       sgrid.callEvent("onGridReconstructed",[]); //will correct  sub-grid size after data loaded in it
  });

Answer posted by Tam Le on Aug 27, 2008 19:28
Thanks for your support so much. It works greatly now
Answer posted by Tam Le on Aug 28, 2008 01:37
Hi,

The solution doesn't work when I load data for sub grid from a string instead of the  xml file

function initSubGrids(sgrid){
  ....................
  sgrid.loadXMLString(xmlString,function(){
       sgrid.callEvent("onGridReconstructed",[]); //will correct  sub-grid size after data loaded in it
  });

What should I do now ?
Thanks for your support so much !

Regards,
Tam

Answer posted by Support on Aug 28, 2008 05:38
The loadXMLString is sync. command, which cause some pretty complex timing issues 
To workaround issue, you can use next code in case of loadXMLString

  sgrid.loadXMLString(xmlString);
  window.setTimeout(function(){
       sgrid.callEvent("onGridReconstructed",[]); //will correct sub-grid size after data loaded in it
  },1)

Answer posted by Tam Le on Aug 29, 2008 01:37
My issue is resolved now. Thanks so much