Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Florante Kho on Aug 27, 2009 01:47
open dhtmlx forum
Sub grid initialization


Hi,

I am working on a grid with a subgird. But when I tried to access the subgrid using

var sub=mygrid.cellById(rowId,cellInd).getSubGrid();

it says that

mygrid.cellById(rowId, cellInd).getSubGrid is not a function

http://i571.photobucket.com/albums/ss155/Florante__/screenshot73.jpg

here is my included files

    <script src="../../codebase/dhtmlxcommon.js"></script>
    <script src="../../codebase/dhtmlxgrid.js"></script>        
    <script src="../../codebase/dhtmlxgridcell.js"></script>    
<script src="../../codebase/excells/dhtmlxgrid_excell_grid.js"></script>
    <script src="../../codebase/excells/dhtmlxgrid_excell_sub_row.js"></script>


Did I miss something?

Thanks

Florante

Answer posted by dhxSupport on Aug 27, 2009 02:41
Please make sure if you are calling var sub=mygrid.cellById(rowId,cellInd).getSubGrid(); after sub grid was already initialized. If you need catch moment of sub grid initialization you can use "onSubGridCreated" event. This event occurs when the creation of a sub-grid was initiated. Event pass the following parameters: 
* sub - sub-grid object;
* rId - id of the related row;
* rInd - index of the related row.
You can use this event to change sub grid loading source:
grid.attachEvent("onSubGridCreated",function(sub,id,ind,value){
  //sub - subgrid object
  //value - value from XML for related cell
  sub.load(url);
  return false; //block default logic });



Answer posted on Aug 27, 2009 02:47

I called up the function on onEditCell

mygrid.attachEvent("onEditCell",doOnCellEdit);

 

which is declared after the call to init

  mygrid.init(); 
  mygrid.attachEvent("onEditCell",doOnCellEdit);
  mygrid.loadXML("grid1.xml");

So I bellieved that mygrid is already iniitallized when the onEditCell event fired up.

 

Thanks

 

Florante