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

feat(table): support dynamic column definitions #5545

Merged
merged 17 commits into from
Jul 28, 2017

Conversation

andrewseguin
Copy link
Contributor

Move the base row's column diff check to the table's change detection to control timing better. The table should have its content checked before reviewing the header/data row columns in case column definitions have been added/removed.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 6, 2017
*/
private _columnDefinitionsByName = new Map<string, CdkColumnDef>();
/** Map of all the user's defined columns (header and data cell template) identified by name. */
private _columnDefinitionsMap = new Map<string, CdkColumnDef>();
Copy link
Member

Choose a reason for hiding this comment

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

Why change this? I liked the old name (since I generally dislike Hungarian notation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfamiliar with ByName over Map but I don't really have a preference

Copy link
Member

Choose a reason for hiding this comment

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

"by name" is referring to how the map is indexed.

* Check if the header or rows have changed what columns they want to display. If there is a diff,
* then re-render that section.
*/
private _checkColumnsChange() {
Copy link
Member

Choose a reason for hiding this comment

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

_renderUpdatedColumns or _renderColumnUpdates?

ngAfterContentInit() {
// TODO(andrewseguin): Throw an error if two columns share the same name
/** Update the map containing the content's column definitions. */
private _refreshColumnDefinitionsMap() {
Copy link
Member

Choose a reason for hiding this comment

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

_cacheColumnDefinitionsByName?

@@ -22,6 +22,18 @@
.demo-row-highlight-even { background: #ff0099; }
.demo-row-highlight-odd { background: #83f52c; }

.mat-card {
Copy link
Member

Choose a reason for hiding this comment

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

Should prefix with a demo- style

@andrewseguin
Copy link
Contributor Author

Made changes, ready for review

}

ngDoCheck() {
if (this._isViewInitialized && this.dataSource && !this._renderChangeSubscription) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment that explains what you're doing with DoCheck and why it's necessary?

@andrewseguin
Copy link
Contributor Author

Added comment about ngDoCheck

@jelbourn
Copy link
Member

@andrewseguin is this PR still good? Not sure if it was tied to your other PR WRT change detection

@andrewseguin
Copy link
Contributor Author

It's still good, just will need a tweak or two when rebased with the other PR

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn
Copy link
Member

@andrewseguin there's one lint error, can add merge ready when fixed

@andrewseguin andrewseguin added action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jul 25, 2017
@andrewseguin andrewseguin merged commit 66e222f into angular:master Jul 28, 2017
@andrewseguin andrewseguin deleted the table-dynamic-columndef branch November 28, 2017 20:36
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants