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

Table Column Sorting #210

Merged
merged 3 commits into from
Oct 11, 2019
Merged

Table Column Sorting #210

merged 3 commits into from
Oct 11, 2019

Conversation

StevenUlmer
Copy link
Contributor

closes #180

Currently we have the ability to either have every column on a table sortable or none of them. There
are certain cases where we want to be able to just sort by a couple columns on a table. This provides a way for an implementor to decide which columns can be sortable on a table or which columns they want to not be sortable. If a column doesn't contain the sortable binding it will default to whatever is in the table config.

@StevenUlmer StevenUlmer added the feature New feature request label Sep 27, 2019
@grahamhency grahamhency changed the base branch from master to v1.3.0 October 2, 2019 15:47
@grahamhency grahamhency added this to the v1.3.0 milestone Oct 2, 2019
Copy link
Contributor

@grahamhency grahamhency left a comment

Choose a reason for hiding this comment

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

Left some comments, I think maybe we can simplify this a little bit.

sortConfig?: GoTableSortConfig,
tableData: any[]
} = this.localTableConfig;

if (tableData && sortable) {
if (tableData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to keep this because this will restrict sorting on a table level, not a column level.

@@ -71,6 +72,14 @@ export class GoTableComponent implements OnInit, OnChanges {
this.renderTable();
}

ngAfterContentInit(): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we default sorting to true on a column, then we won't have to worry about any of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@grahamhency We can default sorting to true, but not defaulting it allows us to have a little more flexibility in how the table is implemented. This way instead of just turning sorting off for a couple columns, we can turn off sorting for the entire table and then enable sorting on a couple columns. The only way to do this is to always keep track of sorting on the column instead of the table, but if this isn't something we care about theres a few things I can clean up here that wouldn't be necessary.

@grahamhency
Copy link
Contributor

@StevenUlmer did you want to have a discussion about the comments I left on this? Also, we'll want to add documentation for this.

Copy link
Contributor

@grahamhency grahamhency left a comment

Choose a reason for hiding this comment

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

@StevenUlmer what if we pass the sortable property of the table into the column and use that as the default for the column?

@Input tableSortable: boolean;
@Input sortable: boolean;

ngOnInit(): {
  if (this.sortable === undefined) {
    this.sortable = this.tableSortable;
  }
}

@StevenUlmer
Copy link
Contributor Author

@grahamhency I've removed that afterContentInit by changing some of the html. Can you take another look?

Copy link
Contributor

@grahamhency grahamhency left a comment

Choose a reason for hiding this comment

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

This functionality looks good. Ready for some documentation.

Currently we have the ability to either have every column on a table sortable or none of them. There
are certain cases where we want to be able to just sort by a couple columns on a table. This provides
a way for an implementor to decide which columns can be sortable on a table or which columns they want
to not be sortable.
@StevenUlmer
Copy link
Contributor Author

@grahamhency Documentation has been written

@grahamhency grahamhency merged commit 01d00a3 into v1.3.0 Oct 11, 2019
@grahamhency
Copy link
Contributor

Merged, thanks for writing the docs!

@grahamhency grahamhency deleted the table_column_sort branch October 11, 2019 16:43
@grahamhency grahamhency mentioned this pull request Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants