Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Michael on Jun 18, 2009 11:29
open dhtmlx forum
Add new rows to Grid with subgrid

I want to have a grid with subgrid.

In your example, your grid already has subgrids existing when loaded via the XML file. Is it possible to have grid with no subgrids pre-existing?

For example, lets say I have 1 row in my grid. I then want to add data via a subgrid to row number 1. Is that possible?
Answer posted by dhxSupport on Jun 19, 2009 02:34
To load sub grid one of the cells in the row should has "sub_row_grid" type.You can change type of the any cell in the row using method setCellExcellType(rowId, cellIndex, type):
mygrid.setCellExcellType("row1", 0, "sub_row_grid");

You can change value of that cell to point it to the sub grid file:

mygrid.cellById("row1",0).setValue("subgrid.xml");

Or you can use "onSubGridCreated" event to load sub grid from any other supported loading types:

mygrid.attachEvent("onSubGridCreated",function(sub,id,ind,value){
  //sub - subgrid object
  //value - value from XML for related cell
  sub.loadXMLString(any necessary xml string)
  //or mygrid.load("grid.xml”);
  return false; //block default logic });