-
Notifications
You must be signed in to change notification settings - Fork 2.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
group by with object array and string array #857
Conversation
Changes Unknown when pulling c04c671 on dj-grouping-by-column-name into ** on master**. |
Changes Unknown when pulling a26432f on dj-grouping-by-column-name into ** on master**. |
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.
Minor stuff only pal, good job 👍
@@ -21,7 +21,7 @@ class RowGrouper { | |||
|
|||
groupRowsByColumn(rows, columnIndex = 0) { | |||
let nextColumnIndex = columnIndex; | |||
let columnName = this.columns[columnIndex]; | |||
let columnName = this.columns.length > 0 && typeof this.columns[columnIndex] === 'string' ? this.columns[columnIndex] : this.columns[columnIndex].key; |
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.
Is the length ever <=0
?
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.
yeah - if you render the grid before grouping which I want to - columns here are the grouped columns not all grid columns
@@ -31,7 +31,10 @@ class GroupedColumnsPanel extends Component { | |||
|
|||
renderGroupedColumns() { | |||
return this.props.groupBy.map(c => { | |||
return (<GroupedColumnButton key={c} name={c} onColumnGroupDeleted={this.props.onColumnGroupDeleted}/>); |
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.
Would rather not repeat the jsx assignments, it can be:
const groupedColumnButtonProps = {
columnKey: c,
name: c,
onColumnGroupDeleted: this.props.onColumnGroupDeleted,
key: typeof c === 'string' ? c : c.key
}
return <GroupedColumnButton {...groupedColumnButtonProps} />;
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.
got it 👍
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.
But the props change - c is either a string or an object. I'll work it out
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.
it's doing that check in the key assignment in my snippet, you can do it for what changes
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.
just needed to do it for the other props too name and key
Done.
@@ -95,7 +95,7 @@ const DefaultRowGroupRenderer = (props) => { | |||
return ( | |||
<div style={style} onKeyDown={onKeyDown} tabIndex={0}> | |||
<span className="row-expand-icon" style={{float: 'left', marginLeft: marginLeft, cursor: 'pointer'}} onClick={props.onRowExpandClick} >{props.isExpanded ? String.fromCharCode('9660') : String.fromCharCode('9658')}</span> | |||
<strong>{props.columnGroupName} : {props.name}</strong> |
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.
What does this change in the actual render? can you show?
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.
so it would say
sellerName: ITV
I just want it to say the value of the group not the column name i.e. ITV
We could make that optinal - but to me it just looks messy
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.
My main concern would be breaking this for people that are already using it, because they are expecting the previous and we will change it in our core and break their functionality
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.
sure - then I'll look at making that optional
Changes Unknown when pulling 3249711 on dj-grouping-by-column-name into ** on master**. |
@@ -95,7 +95,7 @@ const DefaultRowGroupRenderer = (props) => { | |||
return ( | |||
<div style={style} onKeyDown={onKeyDown} tabIndex={0}> | |||
<span className="row-expand-icon" style={{float: 'left', marginLeft: marginLeft, cursor: 'pointer'}} onClick={props.onRowExpandClick} >{props.isExpanded ? String.fromCharCode('9660') : String.fromCharCode('9658')}</span> | |||
<strong>{props.columnGroupName} : {props.name}</strong> |
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.
My main concern would be breaking this for people that are already using it, because they are expecting the previous and we will change it in our core and break their functionality
Changes Unknown when pulling e69e2d4 on dj-grouping-by-column-name into ** on master**. |
Description
A few sentences describing the overall goals of the pull request's commits.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
When using grouping you need to override the default toolbar and row renderer to display user friendly names for the columns.
Could only render a custom toolbar by rendering inline in the property declaration rather than via an import
What is the new behavior?
You can pass in the groupBy prop as an object array.
It assumes current behaviour - that groupBy is an array of strings.
If it is not it expects the objects to have a key and name property.
It will use name to render the groupBy button and the row grouping header.
The toolbar property can only be a React Element not a function. When defining a Generic custom toolbar that enables filtering and grouping in a separate file in TypeScript, nothing was rendered as it failed this validation.
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information: