Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Antoine on Jun 25, 2009 05:54
open dhtmlx forum
filtering with rowspan

Hello,

I'd like to use a Grid with 9 columns.
The 4 first cells of each row can have a rowspan=2 or rowspan=3
Here is an example of my xml for a rowspan=2
<row id="1">     
<cell rowspan="2">Field 1 </cell>    
<cell rowspan="2">Field 2 </cell>    
<cell rowspan="2"> Field 3 </cell>    
<cell rowspan="2"> Field 4 </cell>
<cell> Field 5 </cell>    
<cell> Field 6 </cell>    
<cell>Field 7</cell>    
<cell >Field 8 </cell>    
<cell> Field 9 </cell>    
</row>
<row id="2">
<cell> </cell>    
<cell > </cell>    
<cell > </cell>    
<cell> </cell>
<cell> Field 5 </cell>    
<cell> Field 6 </cell>    
<cell>Field 7</cell>    
<cell >Field 8 </cell>    
<cell> Field 9 </cell>    
</row>

The display of the table is ok but I also want to use filtering on every column and I have 2 problems:
- when I filter on one of the 4 first columns, I only get the first row of the rowspan, I would like to get all rows
- when I filter on one of the 5 last columns on a value not in the first row of a rowspan, the grid displays only the 5 last columns without the 4 first.

Is there a way to get the expected behavior? (I define my filters with the function attachHeader())

Thanks!
Answer posted by dhxSupport on Jun 25, 2009 06:36
The rowspan can cause problem for filtering routine if filtering will result in hiding only part of row-spanned rows 
Unfortunately there is no easy way to change existing behavior. If list of values is predefined, you can redefine collectValues method of grid, to provide custom list of options instead of auto-generated one. 
Answer posted by Antoine on Jun 25, 2009 06:46

I don't want to hide part of row-spanned rows.

Let's say I have this

    | B | C

   | D | E

 

So if I filter on the first column with the value A, I would want to get

    | B | C

   | D | E

 

but instead I have

 A  | B | C

 

Answer posted by dhxSupport on Jun 25, 2009 06:51
Unfortunately there is no easy way to change existing behavior. If list of values is predefined, you can catch "onFilterStart" event and return grid in the necessary order. 
Answer posted by Antoine on Jun 25, 2009 07:03

I don't really see how I could use the "onFilterStart" event to get the expected behavior.

Could you give some more details please?

Thank you!

 

Answer posted by dhxSupport on Jun 25, 2009 07:08
"onFilterStart" could be used to block default grid filtering and return rows in the necessary order:
mygrid.attachEvent("onFilterStart",function(indexes,values){
mygrid.clearAll();
mygrid.load("grid_with_necessary_rows_order.xml");
return false;
});