Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stevo on Nov 13, 2008 07:55
open dhtmlx forum
[GRID] [SUBROWS]

How to force grid to collapse already opened subrows if user opens another one by clicking on [+] button.
Answer posted by Support on Nov 13, 2008 09:51
You can close|open sub-levels programmatically by

grid.cell(i,j).open();
grid.cell(i,j).close();

but there is no any event in current version of grid, which can be used to organize necessary behavior
You can add any custom code to the 
  dhtmlxgrid_excell_sub_row.js, line 72
  dhtmlXGridObject.prototype._expandMonolite=function(n,show,hide){

Answer posted by Stevo on Nov 13, 2008 12:14
I've tried modifying it. In code outside this file I've just used collapsMonolite() function to close all rows, however I do not know on which object I can call it within dhtmlXGridObject.prototype._expandMonolite=function(n,show,hide){...
I've tried 'this' and 'this.grid' but it always returns object undefined error. Can you give me an exact code that I should put into   dhtmlXGridObject.prototype._expandMonolite=function(n,show,hide){ to collapse all subrows?
Answer posted by Stevo on Nov 14, 2008 01:36
Got it... not sure if it is absolutely correct but it works for now...

I've changed
...
            d.className="dhx_sub_row";
            that.objBox.appendChild(d);
            that._detectHeight(d,td)           
        }
   
        if (!that._flow) {
...
to
...
            d.className="dhx_sub_row";
            that.objBox.appendChild(d);
            that._detectHeight(d,td)           
        }
       
                that.selectRow(row);  
                that.getAllRowIds(",").split(",").each(function(id) {
                    if ((that.rowsAr[id]._expanded) && that.rowsAr[id]!=row)
                    that.cellById(id,0).close();
                });
   
        if (!that._flow) {
...