Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by DavidO on May 05, 2008 15:23
open dhtmlx forum
setSubGrid per row

Hello. I got mygrid.setSubGrid( subgrid1, column, field ); working. What I want to do now is set which editor is used per row and same column. So I would do mygrid.setSubGrid( subgrid1 ...) for one row and then mygrid.setSubGrid( subgrid2 ...) for another row. Is that possible?

Thank you for all your help.
Answer posted by Support on May 07, 2008 01:53
The default implementation was not designed for such use-case, but it can be achieved with next custom code
    mygrid.attachEvent("onEditCell",function(stage,id,ind){
       if (stage == 0 && ind == INDEX ){      // if edit executed against necessary column
           //code called before edit operation
          this.setSubGrid(some_grid[id],column,field)      // attach necessary subgrid based on row ID
          this.editor=this.cells(id,ind); // recreate editor for cell
       }
       return true;
    });
Answer posted on May 07, 2008 12:16
Thank you for your help but I have some problem.

When I use this.setSubGrid(some_grid[id],column,field); I get no combo box and an error "grid has no properties" on line 64 of dhtmlxgrid_excell_grid.js. This line in my file is grid.entBox.style.display="none";. I print out  alert(grid); and it is 'undefined'.

Do I need to setup some_grid[id] on initialization?

I thought some_grid was an object but some_grid[id] tries to treat it as an array?

Any help is appreciated.
Answer posted by Support on May 08, 2008 04:23
>>Do I need to setup some_grid[id] on initialization?
The some_grid in provided code is not some global structure but need to be replaced by some custom code.
You want to define different sub-grids for different sub-rows, so there must be some way to detect, which grid related to which row

    this.setSubGrid(some_grid[id],column,field)  
means that in that moment you know the ID of row and must get related grid ( how it will be done depends on your code ), the some_grid here is one of possible solutions, which may store sub-grid instances inside an array.
Answer posted on May 08, 2008 10:18
Hi. I did replace some_grid with the names of my grids. I just put that there for example. I still get the error. I will keep trying to figure it out. Thank you.
Answer posted by Support on May 14, 2008 09:51
If problem still occurs for you - please send any kind of the sample where error can be reconstructed ( you can send it directly to support@dhtmlx.com )