-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Nested Grouping (multiple column grouping) - Fully Working #522
Conversation
Brief description of the project status
fixes of indentation problems
fixind indentation problems
Something's off here. It shouldn't be that slow. |
I think the problem is that you're doing needless exponential work in extractGroups(). Looking at your core loop:
On every iteration, you're rescanning the group rows from scratch ignoring and overwriting the previous groups ("group.groups = grp"). Instead, you should do this sequentially. First, break up the passed in rows into groups. Next, if there's another grouping level, iterate over found groups and call extractGroups(group.rows) on its rows recursively. |
I know the performance is a killer and I mentioned it, I did it recursively, I couldn't find any other way of implementing it but I have the impression it's also exponential each time you pass a level in terms of performance. And I'm almost sure the problem is in the function "extractGroups()", it's most probably exponential. That was the only way I could find without losing the reference to previous level of group, if you find another way, feel free to share because I passed a couple weeks on this issue. I seriously don't know how else to do it. |
Sorry I clicked by mistake on the close button... I've reopened it.. |
I'm not sure if you responded after reading my first comment or both of them. I think my second comment explains where the problem is. |
Yes I saw while I was writing, though I seriously don't know how to tackle it. I did know the problem from the beginning, I mainly wanted it to work at first. If you could fix the code, I'll be more then happy... I did most of it already. |
What about the solution I proposed? Doing it sequentially? function extractGroups() {
|
That was my first approach though when I tried it that way, I was losing reference to the "group" object in which I want to add another "groups" into. I wanted to do it with 2 loops like you seem to mention, but the big thing is that I don't know which object I'm suppose to attach it anymore, I thought passing that reference into a string at first but I decided to stop since this was ugly code and error pron. |
I really don't get what you're saying.
|
Oh boy you made my day here, your code does seem to fix the exponential... Thanks for the optimization!!! I did try it with 50k and it's smooth like it's been since the beginning.. wow awesome. |
To be honest, I don't feel confident merging this code. Since it's in all new files and there's no diff in the pull request, I can't even review it easily. As a first step, please clean up the code a bit by using the same formatting and spaces instead of tabs. Make the fix I suggested and clean up unnecessary code. Also, please merge the changes into the same files so that GitHub can display a diff. |
Ok I see, I'll rename the files though I'm not sure about the spaces instead of tabs as you mentioned... You want me to do 2 spaces instead of a tab in each line there is, is that it? Thanks a lot for the code fix!!! |
There's something that will break a portion of your code, I don't know if you will accept it or not but before I go ahead with the changes, I need some feedback on this!!! You handle your group by a property on the group object of ".value", in which you keep the name of the collapsed/expanded groups inside the "collapsedGroups" variable, that is working fine in 1 level like you always had but isn't working with multiple levels because of collision of possible names as for an example the duration is "0" and you save 0 inside the variable but then I add a second grouping and the % complete is also "0", you can see that it ain't working anymore.. So the way I fixed this issue is by creating a new property of ".grouping" and keeping a trace of the level I'm at, so instead of just keeping "0" in the "collapsedGroups" variable, I keep this instead: "duration:0-->percentComplete:0", this says that at that place the group is collapsed, so there's no collusion. Example inside the html code: and here the .value is replaced by .groupby AFTER with .groupby |
This include the code fix with 50k rows
That's one of the things that I think could use some work. The string concatenation-based ids for groups look less than ideal to me (if only for the fact that group by values may contain ":"). What about making .expandGroup() take in a variable list of parameters, one for each group level? I.e. .expandGroup(0) would expand the first level group with value 0 while .expandGroup(0, 'high') would expand the 'high' subgroup of the 0 group. |
Hmm I tried implementing it and was close to something, just to find out that the proposition you give does not holds enough information as for the full path of levels. When you say .expandGroup(0, 'high'), that could work but would have the effect of closing that same value in every other subgroup of the same level number, that's the main problem I had at the beginning, closing it in 1 group was reflected in other groups as well... That's why I did it with the string, like so "duration:0-->percentComplete:0" there is only 1 in the all dataset, even if there's ":" like you said it doesn't matter at all, I look for the complete string for comparison, I'm not parsing it or anything, so even if you get something like this "dura:tion:0-->percent:complete:0", you would still have only 1 possibility in the dataset. I seriously don't see a problem with the ":", that doesn't bother my string compare at all. By the way, when you put in your code .expandGroup(0), you consider this a the value right? Or is it the index position of the first group? From the code, I think it's the value but just want to make sure... if it's the index, I can do that in my code too. Any more suggestions? |
This reverts commit 1efc84f.
This is working with a .groupby String to expand/collapse. Ex.: dataView.expandGroup("duration:10-->percentComplete:55");
I just made a commit of my latest changes and cleanup you asked for, though it still has my own implementation with a string instead of value even if you are still a little concerned about it, for now that is my latest code which is fully working with 50k rows. I'll wait for your suggestions if you have any... |
Hey Michael, did you had a chance to look into the code change? |
Sorry, been really busy. On Tue, Jan 29, 2013 at 3:06 PM, Ghislain B. notifications@github.comwrote:
|
Without this change, the demo was only expanding/collapsing the first level and not all levels of grouping.
I'm very interested in adding this functionality, but we got a release at On Tue, Jan 29, 2013 at 3:09 PM, Michael Leibman
|
No problem take the time it takes to review it and see if we need to change anything. No rush on my side, I already started using it as is on couple reports at work, it's working as expected and fast like it has always been. Even if there is changes at this point, it shouldn't be major anyway. Your work is more important ;) |
There were too many changes I had to make, but also add a lot, so I started with your code and extended it - 90964ce. |
Ok well at least I made a big big contribution on adding that nice missing feature :) After testing it, I see something that might be a little hiccup... You've added the total on last line of each row, it might be a little confusing at first, I figured it out after it was summing even previous groups. As for the rest, it looks nice this way :) |
Indeed you did :) Could you clarify what the problem you see is? Each group level can On Tue, Feb 26, 2013 at 9:45 PM, Ghislain B. notifications@github.comwrote:
|
My bad, I got confused and didn't inspect properly, I thought the bottom totals were in fact a Grand Total incremented after each group, but in fact it just happen that the last group had a lot less in it's total... I would recommend you update your README.md file as well to mention that new multi-level grouping with independent aggregators functionality. As for the rest..Awesome!!! Thanks for implementing it Michael |
Thanks! I'll add a wiki page on it later when I have some more free time. What's changed:
On Wed, Feb 27, 2013 at 7:36 AM, Ghislain B. notifications@github.comwrote:
|
Based on the original pull request (mleibman#522) by ghiscoding. Deprecated DataVIew APIs (will continue to work): - .groupBy() - .setAggregators() New DataView APIs: - .getGrouping() - .setGrouping(groupingInfo) - .setGrouping([groupingInfo1, groupingInfo2, ...]) - .collapseAllGroups() - .collapseAllGroups(level) - .expandAllGroups() - .expandAllGroups(level) - .collapseGroup(groupingKey) - .collapseGroup(level1value, level2value, ...) - .expandGroup(groupingKey) - .expandGroup(level1value, level2value, ...) Grouping info options (for use in .setGrouping() calls): - getter - formatter - comparer - aggregators - aggregateCollapsed - aggregateChildGroups - collapsed New Group fields: - level - groups - groupingKey Also fixed 0-handling in default aggregators.
Based on the original pull request (mleibman#522) by ghiscoding. Deprecated DataVIew APIs (will continue to work): - .groupBy() - .setAggregators() New DataView APIs: - .getGrouping() - .setGrouping(groupingInfo) - .setGrouping([groupingInfo1, groupingInfo2, ...]) - .collapseAllGroups() - .collapseAllGroups(level) - .expandAllGroups() - .expandAllGroups(level) - .collapseGroup(groupingKey) - .collapseGroup(level1value, level2value, ...) - .expandGroup(groupingKey) - .expandGroup(level1value, level2value, ...) Grouping info options (for use in .setGrouping() calls): - getter - formatter - comparer - aggregators - aggregateCollapsed - aggregateChildGroups - collapsed New Group fields: - level - groups - groupingKey Also fixed 0-handling in default aggregators.
When frozen columns is enabled the height of the header row is missing in the height calculations. This change calculates the values also in this specific case so they are available later.
I would like to contribute my code to Slickgrid, after working intensely on this project I finally made a fully working Nested Grouping (multiple column grouping).
Notes / things to consider:
Hopefully my code will be implemented with yours, I spent a lot time on time.
Thanks
Ghislain B.