Smart-Table icon indicating copy to clipboard operation
Smart-Table copied to clipboard

Add possibility to group rows on a property

Open eirikbell opened this issue 10 years ago • 8 comments

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?

eirikbell avatar Dec 05 '14 06:12 eirikbell

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

lorenzofox3 avatar Dec 05 '14 11:12 lorenzofox3

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:

The files needed are stGroup.js, stGroup.html, stSortGroup.js, stGroupSearch.js and smart-table.debug.js or smart-table.min.js

alon-s avatar Feb 06 '15 18:02 alon-s

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?

eirikbell avatar Feb 10 '15 08:02 eirikbell

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.

lorenzofox3 avatar Feb 12 '15 04:02 lorenzofox3

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. ;-)

lee-40square avatar Feb 22 '15 18:02 lee-40square

I was updated the plunk of @eirikbell to http://plnkr.co/edit/VxiVPIQAiKmSW5v2KxLD?p=preview

moshfeu avatar Feb 16 '16 10:02 moshfeu

Ditto on this being a super desirable feature.

radusuciu avatar May 07 '16 22:05 radusuciu

any update on if this was/is added?

Hughesm avatar Jun 08 '16 18:06 Hughesm