Skip to content
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

Merged
merged 8 commits into from
Jul 11, 2017

Conversation

d4nj0nes
Copy link
Contributor

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")

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

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")

[ ] Yes
[x] No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling c04c671 on dj-grouping-by-column-name into ** on master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling a26432f on dj-grouping-by-column-name into ** on master**.

Copy link
Contributor

@diogofcunha diogofcunha left a 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;
Copy link
Contributor

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?

Copy link
Contributor Author

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}/>);
Copy link
Contributor

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} />;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it 👍

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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>
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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

@coveralls
Copy link

Coverage Status

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>
Copy link
Contributor

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

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e69e2d4 on dj-grouping-by-column-name into ** on master**.

@diogofcunha diogofcunha merged commit 6900b30 into master Jul 11, 2017
@amanmahajan7 amanmahajan7 deleted the dj-grouping-by-column-name branch March 14, 2019 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants