Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Eduardo Santisbón on Oct 23, 2009 16:02
open dhtmlx forum
Is there a way to automatically open a subrow in a grid loaded by XML?

I want to specify in the XML that a column of type sub_row must be open after the XML is loaded by the grid. Is this possible?
Answer posted by Stanislav (support) on Oct 26, 2009 03:58
You can use 

mygrid.load(url,function(){
       mygrid.forEachRow(function(id){
              if (mygrid.getRowAttribute(id,"open"))
                   mygrid.cells(id,0).open();
       })
})

where 0 - index of sub_grid column
With such code, any rows which have "open" attribute will be opened after xml loading. 
Answer posted by Eduardo Santisbón on Oct 26, 2009 19:36

Yes, We already have code like that; we where hoping for a way to avoid the delay that occurs after the grid is populated/rendered and then some of the subrows are opened with script.

I guess we have to live with that for now.

Thanks anyway!

Answer posted by dhxSupport on Oct 27, 2009 01:32
To not wait till all rows are loaded you can use "onRowCreated" event. This event occurs after a row was created in the grid, and was filled with data. onRowCreated event passes the following parameters:
rId - id or the row;
rObj - row object;
rXML - related XML (if available).
 mygrid.attachEvent("onRowCreated", function(rId,rObj,rXml){
if (mygrid.getRowAttribute(id,"open"))
mygrid.cells(id,0).open();
});


Answer posted by Eduardo Santisbón on Oct 27, 2009 10:21

With the onRowCreated event approach, we are still seeing a delay from when the rows are rendered (and they are rendered with the subrow closed by the way) to when the subrows seems to be opened. But now it seems to be an additional issue because the rows with this code are truncated in height (the grid has multiline enabled).

The original approach of opening the subrows on the onXLE event with the delay was just a cosmetic issue for us. But now we are facing other problems with subrows, smart rendering and sorting that are indeed critical for us. We will contact support for those problems but if you still needed, we can provide a XML to reproduce the problem with the onRowCreated approach suggested here.

Thanks for your help!