Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by andreea on Aug 18, 2008 06:05
open dhtmlx forum
On onclik the row(containing a subgrid ) expands and I get this error

i do this: onclick='mygrid.cells(mygrid.getSelectedRowId(),0).open(); someFunction();'

somefunction contains: 
....
if (mygrid.getSelectedRowId())
  {
  if(mygrid.cells(mygrid.getSelectedRowId(),mygrid.getColumnsNum()-1).getValue()=='' || mygrid.cells(mygrid.getSelectedRowId(),mygrid.getColumnsNum()-1).getValue()=='i' )
  {
  //new route not yet inserted
  alert('<?=JS_INSERT_NEW_ROUTE_BEFORE_ADDING_NEW_STOPS?&gt;');
  return;
  }
  else
  {
  var sub=mygrid.cells(mygrid.getSelectedRowId(),0).getSubGrid();
  if (sub.getRowsNum()&gt;=2 &amp;&amp; sub.cells(sub.getRowId(sub.getRowsNum()-2),0).getValue()=='')
  {
  alert('<?=JS_VALIDATION_STOP_NEW?&gt;');
  return;
  }
  else
  {
  sub.addRow(sub.getRowsNum()+1,'',sub.getRowsNum()+1);
  return;
  }  
  }

  }
  else
  {
  alert('<?=JS_SELECT_ROUTE?&gt;');
  return;
  }

On onclik the row(containing a subgrid ) expands and I get this error: his.hdr.rows[0] has no properties
[Break on this error] for(var i=0;i<this.hdr.rows[0].cells.length;i++){ ,afterward  

if I put an alert(mygrid.getSelectedRowId()); at the begining of the function the error doesn't appear anymore;

Answer posted by Support on Aug 18, 2008 07:23

When you call .open for subgrid first time, it loads data from server , and this loading is async. Which means the code in someFunction executed before subgrid fully loaded

You need to use onXLE event of subgrid or onSubGridLoaded event of master grid to catch moment when data in subgrid  loaded and you can poll info from it.