-
Notifications
You must be signed in to change notification settings - Fork 10
GridCountLabel
supports a new excludeParents
prop
#4067
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new excludeParents
prop to the GridCountLabel
component to exclude parent records from the record count calculation. This feature is useful for tree grids where counting grouping/parent rows can be confusing.
- Added
excludeParents
boolean prop toGridCountLabelProps
interface - Modified count calculation logic to filter out parent records when both
includeChildren
andexcludeParents
are true - Updated CHANGELOG.md with the new feature
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
cmp/grid/helpers/GridCountLabel.ts | Added excludeParents prop and implemented filtering logic to exclude parent records from count |
CHANGELOG.md | Added changelog entry documenting the new excludeParents property |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
unitLabel = count === 1 ? singularize(unit) : pluralize(unit); | ||
let count = includeChildren ? store.count : store.rootCount; | ||
if (excludeParents && includeChildren) { | ||
count = store.records.filter(it => !it.children.length).length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filtering operation on store.records
is performed on every render when excludeParents
and includeChildren
are both true. Consider caching this calculation or using a memoized getter from the store to avoid repeated array filtering operations.
Copilot uses AI. Check for mistakes.
Hi - this is a familiar need for us, although it's been a while since we last discussed it. It's a tricky one. See https://xhio.slack.com/archives/C4MF830H5/p1540589092038300 and https://xhio.slack.com/archives/C4MF830H5/p1701803743851219 A few things we should still consider:
|
Doesn't seem to matter, is desired. See demo toolbox branch:
I am testing on a grid with 16k rows and I don't see any issues. Maybe on very large grids this would be a reason not to pre-compute
Certainly could do that. Could also warn in console to alert developer that that configuration doesn't make sense.
I mentioned in description at top that whatever was done to |
I just tested on our toolbox companies grid, which is not a tree grid, but a grid with grouping. The problem of excess row counts (or counting groups and children when I only want children counted) doesn't happen there because the grouping is done at the agGrid level, not at the store level, so there are no parent/child relationships in the store. Every record is a root record. So, just to help the discussion and limit the scope of problem, it only applies to when |
I found I need this feature on a tree grid where counting the grouping rows confuses things.
If we wanted to go further, seems like the store could also support some more getters, and then the logic inside
GridCountLabel
would be simplified.Also, if this feature has legs, I would apply the same changes to
StoreCountLabel
.Hoist P/R Checklist
Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.
develop
branch as of last change.breaking-change
label + CHANGELOG if so.If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.