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

Fix grouping example #1311

Merged
merged 4 commits into from
Oct 29, 2018
Merged

Fix grouping example #1311

merged 4 commits into from
Oct 29, 2018

Conversation

amanmahajan7
Copy link
Contributor

@amanmahajan7 amanmahajan7 commented Oct 21, 2018

image

@malonecj malonecj changed the base branch from next to master October 22, 2018 12:07
@malonecj malonecj changed the base branch from master to next October 22, 2018 12:07
@malonecj
Copy link
Contributor

Hey @amanmahajan7 Since this is a minor change we should have master as the base branch rather than next

@amanmahajan7
Copy link
Contributor Author

@malonecj master does not have the latest code, we should catchup with next and I can create a new PR with master as the base branch

@amanmahajan7 amanmahajan7 changed the base branch from next to master October 24, 2018 14:23
Add HeaderRowType constant
Use column name instead of key for group name
Copy link
Contributor Author

@amanmahajan7 amanmahajan7 left a comment

Choose a reason for hiding this comment

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

There are tow pending issues

  1. Drag preview is incorrect and I am not sure why. It works fine in the immutable example

image

  1. Group row is incorrectly selected. Need to decide how to handle it

image

let groupedRows = this.resolver.getGroupedRows(rows, columnName);
let keys = this.resolver.getGroupKeys(groupedRows);
let dataviewRows = this.resolver.initRowsCollection();

for (let i = 0; i < keys.length; i++) {
let key = keys[i];
let isExpanded = this.isRowExpanded(columnName, key);
let rowGroupHeader = {name: key, __metaData: {isGroup: true, treeDepth: columnIndex, isExpanded: isExpanded, columnGroupName: columnName}};
let rowGroupHeader = {name: key, __metaData: {isGroup: true, treeDepth: columnIndex, isExpanded: isExpanded, columnGroupName: columnName, columnGroupDisplayName}};
Copy link
Contributor Author

@amanmahajan7 amanmahajan7 Oct 24, 2018

Choose a reason for hiding this comment

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

Added this to show column.name instead of column.key in the group row

};
}

setScrollLeft(scrollLeft) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no longer required as HeaderCell content is wrapped inside a DraggableHeaderCell

@@ -10,11 +10,6 @@ class RowRenderer extends React.Component {
renderBaseRow: PropTypes.func.isRequired
};

setScrollLeft = (scrollBy) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not required as we introduced renderBaseRow

import Row from './Row';
import cellMetaDataShape from 'common/prop-shapes/CellActionShape';
import * as rowUtils from './RowUtils';
import RowGroup, { DefaultRowGroupRenderer } from './RowGroup';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DefaultRowGroupRenderer does not exist


getSelectedRowColumns = (rowIdx) => {
const row = this.getRowByRef(rowIdx);
return row && row.props ? row.props.columns : this.props.columns;
Copy link
Contributor Author

@amanmahajan7 amanmahajan7 Oct 24, 2018

Choose a reason for hiding this comment

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

This was causing an error for grouped rows

{resizeHandle}
</div>
);

if (rowType === HeaderRowType.HEADER && column.draggable) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrapping HeaderCell content. This has a few benefits

  1. setScrollLeft is not required in DraggableHeaderCell. So this works with frozen columns, it was broken before
  2. It works with any header cell renderer

In the future I would like to clean up header rendering logic so we can easily compose them

DraggableHeaderCell(SortableHeaderCell(SimpleHeaderCell or column.headerRenderer))

if (isDragging) {
return null;
}
return connectDragSource(<div ref={node => this.node = node} style={{cursor: 'move'}}>{this.props.renderHeaderCell(this.props)}</div>);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renderHeaderCell is not passed as a prop

@amanmahajan7 amanmahajan7 removed the WIP label Oct 24, 2018
Copy link
Contributor

@malonecj malonecj left a comment

Choose a reason for hiding this comment

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

This looks good to me

@malonecj malonecj merged commit fd85bb0 into master Oct 29, 2018
@amanmahajan7 amanmahajan7 deleted the am-cm-fix-grouping branch October 29, 2018 13:52
@amanmahajan7 amanmahajan7 mentioned this pull request Oct 30, 2018
8 tasks
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.

2 participants