Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Peter Hoppen on Jun 26, 2009 03:50
open dhtmlx forum
Subgrid Caching

How is it possible, to switch off caching of dataloading for subgrids.
We have a grid with a subgrid. Once a subgrid of a particular row is shown (i.e. the data was loaded), closing and reopening the subgrid does not cause the data (which was changed externally) to be loaded again.
Answer posted by dhxSupport on Jun 26, 2009 04:31
After closing\opening sub grid sub grid's values doesnt caching. Actually after closing sub grid it's object isn't destroyed. When you againg opening sub grid you see the same sub grid which was loaded at the first time. If you want to reload sub grid after each opening you can do that using "onSubRowOpen" event. This event occurs when a sub-row( sub-grid) was opened(closed). 
  grid.attachEvent("onSubRowOpen", function(id,state){
  //any custom logic here
  });

Parameters: 
id - id of row;
state - {bool} open state, true - opened.

Answer posted by Peter Hoppen on Jun 29, 2009 12:33
What custom logic would I have to add to reload ths sub grid after each opening?
Answer posted by dhxSupport on Jun 30, 2009 02:07
Using this  event you can load new xml for the sub grid:
grid.attachEvent("onSubRowOpen", function(id,state){
  if (state){
       var subGrid=grid.cells(id,COLUMN_INDEX).getSubGrid();
       subGrid.clearAll();
       subGrid.load("new_xml_for_sub_grid.xml");
 }
  });

Answer posted by Peter Hoppen on Jun 30, 2009 08:35

Thank You, that works fine except for one problem:

if subgrid load is called from within onSubRowOpen event, the grid is not expanded which causes the subgrid to overlap with follwing rows in the grid (see attachment)

Attachments (1)
Answer posted by dhxSupport on Jun 30, 2009 09:03
Try to change "onSubRowOpen" event handler like following:
 mygrid.attachEvent("onSubRowOpen", function(id,state){
  if (state){
  var subGrid=mygrid.cells(id,0).getSubGrid();
  subGrid.clearAll();
  subGrid.load("sub1.xml",function(){
  subGrid.callEvent("onGridReconstructed",[]);
  });
  }
  });

Answer posted by Peter Hoppen on Jun 30, 2009 09:38
Thank You, that works perfect!