Smart-Table
Smart-Table copied to clipboard
Add possibility to group rows on a property
Hello,
I have a requirement where the data in the collection have to be grouped by one of its properties. It should provide open collapse to its subrows, something like in this plunker from ngGrid: http://plnkr.co/edit/Bo11ckeWFiMyJ4tyLVWC?p=preview
Do you know if anyone implemented this plugin for smart-table? How would you recommend me to approach this if I were to implement the plugin, and would this be a feature you would be interested in a pull request on?
This is not supported at the moment, I think it will require some modifications in the API as well so not sure to do it in the short term
I needed the same feature so I created a directive for groups, a filter for sorting them and a filter for searching in them. Everting is in the src folder in the my fork of this project : https://github.com/alon-s/Smart-Table
The directive is used instead of the body in the html, and the use shoulde look like this:
It needs to get the data in the next format: [ {groupKey : [ row,row,...] } , {groupKey : [ row,row,...] } , ... ]
And in order to apply the sorting and searching in the table element use the stSort and stSearch and send them the filters i created. for example:
I actually looked at something similar, I created a plugin which allows the consumer full control on row html and not interfering with filter and sort. I have a plnkr here:
http://plnkr.co/edit/W5LG23BUGNf2Rrp9zz0t?p=preview
This displays usage of the stGroup directive without interfering with filtering and sorting. I added a custom controller and a select filter to test custom filter.
Some limitations:
- Only grouping on 1 of the properties
- Must be used with the st-safe-src as if asynchronous
- Should not be used for extreme sized datasets as performance on grouping algorithm isnt very effective.
- groupedData is exposed on the scope containing array with key and items array
lorenzofox3: Would you be interested in a pull request on this directive?
Interesting ! Actually, first I would rather see grouping as something non intrusive, on top of smart-table as the grouping operation would be on a different stream than the regular sort,filter, slice operations. So you could keep using pagination, filter and sort independently that the groups. I think we could use a filter to generate the groups. here is a example using a third party filter angular-filter. Of course later we may provide an api on the table controller so the "group state" would be part of the table state and have our specific groupBy filter.
And here's another example http://bazalt-cms.com/ng-table/example/12 (see 13 for example with callback). IMHO this is the only feature missing in Smart Table preventing it from being absolutely perfect. ;-)
I was updated the plunk of @eirikbell to http://plnkr.co/edit/VxiVPIQAiKmSW5v2KxLD?p=preview
Ditto on this being a super desirable feature.
any update on if this was/is added?