-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add sorting to table columns #71
base: master
Are you sure you want to change the base?
Conversation
}; | ||
this.resize = this.resize.bind(this); | ||
this.prevPage = this.prevPage.bind(this); | ||
this.nextPage = this.nextPage.bind(this); | ||
} | ||
|
||
componentWillMount() { | ||
this.setState({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have to setState again, when we already have a default state? because we don't get headers until now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, exactly. I tried to put it in the constructor, but this.props.headers
wasn't defined yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would props.headers
in the constructor work? this
isn't defined at that point, but props
does get passed in as an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good call! Yeah, that worked. I'll update.
looks awesome generally! just put some comments in line, but i would also merge as is. great work. |
Thanks for the feedback, @samuelcole! The one issue I ran into with this is that the pagination makes it so that the columns jump in size when you sort (because there might be a longer column value on pg 2 that suddenly gets bumped to pg 1 on sort). I'm not totally sure how to fix it and am not sure whether having sorting functionality outweighs the weirdness of the column jumpiness, so see what you think and let me know! |
const values = props.values.slice(start, end); | ||
const columns = Object.keys(values[0] || {}); | ||
values = values.slice(start, end); | ||
const columns = props.headers; | ||
const standardColumnWidth = 100; | ||
const wide = (columns.length * standardColumnWidth < window.innerWidth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have wide
in the initial state, but it doesn't seem to be used anywhere -- should this calc (and standardColumnWidth
) be moved to the constructor?
For #11.
TODO: