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

refactor(react-grid): extract table column extension #586

Merged
merged 14 commits into from
Dec 21, 2017
Merged

refactor(react-grid): extract table column extension #586

merged 14 commits into from
Dec 21, 2017

Conversation

kvet
Copy link
Contributor

@kvet kvet commented Dec 15, 2017

BREAKING CHANGES:

In order to improve API readability, we extracted the width and align column properties that the Table and VirtualTable plugins handle into a separate property. Now, the width and align properties in the Grid columns are no longer supported. Use a TableColumnExtension instead:

Before:

const columns= [{ name: 'field', width: 100 }, { name: 'field2' }];

<Grid columns={columns}>
  <Table />
</Grid>

After:

const columns= [{ name: 'field1' }, { name: 'field2' }];
const tableColumnExtensions = [{ columnName: 'field1', width: 100 }];

<Grid columns={columns}>
  <Table columnExtensions={tableColumnExtensions} />
</Grid>

@kvet kvet changed the title [wip]refactor(react-grid): extract table column extension refactor(react-grid): extract table column extension Dec 18, 2017
}));
export const tableColumnsWithDataRows = (columns, columnExtensions) =>
columns.map((column) => {
const columnExtension = getColumnExtension(columnExtensions, column.name);
Copy link
Contributor

Choose a reason for hiding this comment

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

The column.name field is used twice and can be extracted.


expect(tableColumnsWithDataRows(columns, columnExtensions)[0])
.toMatchObject({ align: 'right' });
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add one more test that checks that only the width and align fields will be applied?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I think that these tests are enough

tableColumnExtensions: [
{ columnName: 'amount', align: 'right', cellComponent: HighlightedCell },
{ columnName: 'discount', cellComponent: ProgressBarCell },
],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why there isn't the width extension as in the prev version?

@kvet kvet requested a review from viterobk December 20, 2017 07:40
@kvet kvet merged commit 7f57be2 into DevExpress:master Dec 21, 2017
@kvet kvet deleted the table-column-extension branch December 21, 2017 13:11
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.

4 participants