GroupGridView extends CGridView with following features:
Developed and tested on Yii 1.1.9.
Put groupgridview folder from zip to your protected/extensions.
See code samples in demo.
Main parameters are:
mergeType - how merge is displayed:
simple: column values are merged independently (default) nested: column values are merged if at least one value of nested columns changes (makes sense when several columns in $mergeColumns option, see #11462)firstrow: column values are merged independently, but value is shown in first row of group and below cells just cleared (instead of rowspan) extraRowColumns - array of columns for which every change of value will trigger extra row
above (default) | below$data and $totals inside. 'extraRowTotals' => function($data, $row, &$totals) { if(!isset($totals['sum_age'])) $totals['sum_age'] = 0; $totals['sum_age'] += $data['age']; }
Variable $totals is available in extraRowExpression.
Please consider that subtotals are incorrect when used together with pagination!
You can use it with bootstrap gridview via ext.groupgridview.BootGroupGridView widget.
Since 1.2 you need Yii-bootstrap 1.0 and above.
Extension uses only data that are on current grid page. You should take care about sorting to get correct results.
Total 20 comments
@hiral darji
It seems links are not grouped because they have different URLs (due to different
"id"=>$data->hostel_room_category_facility_id). And that is correct. Otherwise, if they merged you will loss some urls from your grid. You can try without id - it should work:this is my code
this is my code for grideview in this i want to group room_category_name field but with link it is not group. without link its work fine.
@Bluenica
To have model1 in extrarow and model2 in content rows I think you should combine two dataproviders into single one. And then use it in groupgridview. Otherwise grid will not understand when exactly to insert extrarows.
@hiral darji
Could you show the your code snippet ?
hello all,
I have trouble with groupgridview when i merge the column which value has CHtml::link, mergeColumns not work at that time for me.
Reply me as soon as possible.
Thanks in advance.
hello i was wondering if 'extraRowColumns' => array('name'), can also be a dataprovider? is this extension possible for different models?
i have model1 and model2.
I need the model1 to be in the extraRowColumns and model2 as the content of the extraRowColumns.
they're both being passed in my view as dataprovider
great work.. you saved my life :D
Hi, Daniel,
I found that it is controlled by
mergeTypeoption that was not documented. Please try to setI will update docs.
Hi Vitalets,
still not working, I change the order, but resulting the same.
either
or
results are the same.
hi, not possible now. But could be good feature!
Is it somehow possible to generate Tables like this? With a grouped heading above some defined columns.
I assume it should already work exactly this way..
Could you re-check the order of columns in
mergeColumns?see the updated third example.
My point is that "bbb" is split up for "A123" and "A456". not merge since the first "bbb" is belong to "A123" and second one is belong to "A456".
What I need is that "bbb" that is merged only if it has same "A123" see example 2.
Thank you for quick support. Anyway, this is great extension and really useful.
hi, is't it this ?
or please fix formatting in your third sample..
Hi,
I was wondering is that possible to merge hierarchically? For example
merge to be
not
because I will mixed up the hierarchical process.
Thank you.
Hi,
Can I export the groupgridview to excel/pdf?
no. I think it's should be another extension that converts any CGridView 2 pdf(no matter with grouped cells or not).
Can I paginate the gridview so that the merge column is displayed in one page?
currently no. It would be great improvement of extension. But it seems not easy: now it is grouping data already fetched from database, and in you request extension should generate sql to fetch all rows for particular group (if I understand you right). You can have a look on source on github and may be find a pretty solution.
Hi,
Can I export the groupgridview to excel/pdf?
Can I paginate the gridview so that the merge column is displayed in one page?
Thank you for your help.
Cheers,
Daniel
great extension!!
hi fr0d0z,
please see demo, there are plenty of example snippets there
demo site is online!
yes, thank you, I also got notification from hosting. Checking..
Leave a comment
Please login to leave your comment.