Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Gayathri on May 18, 2009 06:36
open dhtmlx forum
Adding sub grid from JS

Hi

i am trying to add a sub grid to a parent grid from JS. Something similar to addRow(). I read in one post that if i add the subgrid's div's innerHTML it will work. The problem i have is it shows a plus sign in the column but it doesnt do anything on click. can you please tell me what could be the problem. I tried passing the sub grid XML also. But it didnt work either.

Am doing like this:

 planGridDetails.addRow(0,  document.getElementById("mySubPlanDetail").innerHTML, 0);

Thanks in advance.

Cheers

Gayathri

Answer posted by Alex (support) on May 18, 2009 08:24

The subgrid should be initialized from xml. But there is the following workaround:

grid.setColTypes("sub_row_grid,ed,ed");
...
grid.init();
grid.addRow(some_id,"1,2,3");

grid.attachEvent("onSubGridCreated",function(subgrid,row_id,cell_index){
 subgrid.setHeader(..);
 ...
 return false
})

So, according to this method:

1) we've defined some value as the xml path (1 in the example);

2)  then we have set  onSubGridCreated event handler to block the default bahaviour (return false) and initialize subgrid using JS.

Answer posted by Gayathri on May 18, 2009 08:28

Thansk very much Alex. Your quick reply is much appreciated. It is resolved now.

 

Cheers

Gayathri