External grouping
The grouping feature is great, but it still assumes that you'll have to bring all the data from the server to the client. Potentially one could want to analyze (group) large amount of data... bla bla... do I really need to explain why there is a need for external grouping? Good.
Now that we established that external grouping is a desired feature, I'd like to propose a potential api for that feature.
$scope.gridOptions = {
useExternalGrouping: true,
onRegisterApi: function (gridApi) {
gridApi.grouping.on.group($scope, function(cols) {
// here we know which columns user grouped by
// provide function to get new grouped data from the server
// update column definitions if needed
});
gridApi.grouping.on.rowExpandedStateChanged($scope, function(row) {
// a particular group is expanded
// get data for that expanded group
});
}
}
This is a rough sketch and I'm sure I didn't think of a lot of things that need to be addressed here, but it's a start of a discussion.
Definitely a nice feature to have! I've implemented something very similar on top of ng-grid last year. In addition to having something like what you're saying, we had also introduced the ability to select a single or multiple groups.
@ist88 Do you have code that could be ported over to ui-grid. This is a feature that I need and I'm willing to add.
I don't have the "ported" code just yet. I'm working on this at the moment. Let me know if you're interested to have this soon though, I can walk you through the idea though (that was implemented in ng)
I'm interested. I need it for my project at my company. If I can add functionality into grouping that would be really cool. I guess the alternative is to do a server sort and then use ui-grid's built in grouping.
@DmitryEfimenko : I think treeView already does a bunch of this - it certainly has the ability to trigger a server get when someone expands a group.
@PaulL1 I looked at the treeView docs. If I'm not mistaken it'll be a lot of boilerplate code to make the external grouping work using this feature. You'd have to add custom buttons to the menu, figure out the levels of data... there's gotta be a better, simpler way.
As a side note, it's kind of hard to understand TreeView examples given because data in these examples does not really make sense.
True, I hadn't thought about the menu behaviour.
I suspect you'd want some sort of blend of treeView and grouping to make this work. To get aggregations for data the grid cannot see then the group headers will have to be calculated server side. If the group headers are calculated server side then you can't use grouping, you need to use treeView (since treeView uses existing rows as headers).
There isn't a lot of logic in the menu handling, maybe factor that into a separate feature that you can make available to both treeView and grouping (or maybe move it into treeBase, and just turn it on and off in each feature - so off by default in treeView, on by default in grouping, but have an "external grouping" option in treeView that turns it on there).
@PaulL1 In ng-grid what I've done was to calculate the headers server side :-).
What I did was to return rows that contained data in cells that we're supposed to render groupings. For example if I wanted to return: -A --A1 --A2 -B --B1 --B2
I had to replace the grid data and simulate grouping by replacing the original grid data with: null null A null null A1 null null A null null A2 null null B null null B1 null null B null null B2
By doing so, I then triggered a group() which would give me the right groupings. Also each row, had a property attached to it to represent the actual group count (calculated on the server side) which was used in the grid header template to render it.
So yes, to @DmitryEfimenko 's point, a lot of boiler plate to get this working.
External grouping is a desired feature.
This is a useful request, but not really in the current roadmap. We have far too many good ideas in the repository already, giving the impression that we have a project riven with defects.
Accordingly, I am leaving the enhancement tag on this, but closing it. If someone would like this functionality, we'd welcome a pull request that adds it.