-
-
Notifications
You must be signed in to change notification settings - Fork 22
Update dataTables.rowGroup.js #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Allan, I don't quite have something right. I tested this with a pageLen of -1, which shows all rows, and it worked fine. However when testing it with pagination, it doesn't work properly. I'll close this pull request and try again after troubleshooting. In the meantime I welcome any thoughts on where I might have missed it. |
|
I approached this from a different angle that fixed my previous issue with pagination. Now the constructor checks if there is more than one group and if the hideIfSame option is false. If either of those conditions exists, then it executes as normal, otherwise the other functions are simply skipped altogether. On a separate issue, I noticed that "No group" (or whatever the emptyDataLabel is set to) was not being treated as an actual group. When a table is rendered, each and every record that is not part of a group had "No group" inserted above it, even if it was part of a continuous group of rows with "No group". Seems like rows falling under the "No group" group itself should be grouped like any other group under a row group . . . :-) Anyway, maybe that was an intentional design decision, but I included a change that treats the "No group" as an actual group. |
|
Made it a little more versatile by giving an option to hide the row grouping if all the rows belong to unique groups (i.e., rowGroup: "name" on the example data with "Tiger Nixon", etc.). Now the two proposed new options are |
|
Absolutely fantastic - thank you! I'm not going to pull it in right now, because if I do it will close and I'll forget to add the documentation and examples for it, so I'll leave it open atm, and hopefully pull it in tomorrow. I think this is a nice addition - thanks! |
|
Thanks, Allan. Very glad to contribute back and happy to see how easy it was through Github. Once you get it pulled, do you know when you might release v1.0.3 on the DataTables site? |
|
In this example: http://live.datatables.net/ripikumo/1/edit - should the rows grouping not be hidden? |
|
It should show the grouping, right? Not all ages are the same but they're not all unique either. |
|
Hmmm. The grouping is unique, but yes you are right that the ages are grouped. But the grouping is still showing as unique. How about this one: http://live.datatables.net/ripikumo/2/edit . The table is filtered to that the rows are unique, but the grouping is still shown. |
|
Well, that's the behavior I intended since it's based on the whole dataset, but I see how you're understanding it. Perhaps in hindsight "hide" isn't as good of a descriptor as "disable"? And perhaps it should actually disable the row grouping through API instead of exiting the extension from the constructor before it does anything more than compare the numer of groups to the number of rows. Alternatively the extension could be updated with the behavior you're expecting. |
|
Been thinking about this over the last few days and I think for the moment I'm going to unmerge the change I'm afraid. What I'd like to see to make this feature complete is support for:
For example I think its a very useful feature and I will add that in future, but I suspect the current implementation will lead to confusion similar to my own. Edit: Created #7 for this |
|
Yeah, I can see how more option would be useful. I hadn't thought about it in the way you had. Meanwhile I use this bit of code to disable the row group when they're all the same: I'll post this in the DataTables forum in case anyone else would like to use it. |
Allan, my first ever pull request for anything -- so my apologies if I don't get it quite right!
At any rate, this change is based on the very last part of this discussion: https://datatables.net/forums/discussion/comment/123641/#Comment_123641
My suggestion was to have an option to hide the row group if all the rows are the same.
I've added an option called "hideIfSame" with a default of false.
Although Github's comparison shows multiple lines changed under the _draw function, the only change was to wrap the loop in an if statement.
Please let me know if you have any questions or if there's anything I can do to help make this better (i.e., convince you to add this feature!).
If you incorporate this, it's available under the same MIT license as the DataTables project.