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

Anyway you could add a "date" field to column types to sort on? #4

Closed
bbennett36 opened this issue Jun 1, 2017 · 10 comments
Closed
Assignees

Comments

@bbennett36
Copy link

I could probably hack something together or edit the current component but I'm sure you could do this more efficiently than me. Just let me know, thanks!

@xaksis xaksis closed this as completed in 7ee0b7c Jun 1, 2017
@xaksis
Copy link
Owner

xaksis commented Jun 1, 2017

Don't sell yourself short friend! You would have done a fine job i'm sure. I used moment to parse/format dates. you can find the changes in version 1.4.0.

@xaksis
Copy link
Owner

xaksis commented Jun 1, 2017

Example usage:
you can add a column like so:

{
          label: 'Created On',
          field: 'createdAt',
          type: 'date',
          inputFormat: 'YYYYMMDD',
          outputFormat: 'MMM Do YY',
          filterable: false,
        },

and your date should look like '20160423' //depending on the format you specify in inputFormat.

@bbennett36
Copy link
Author

Awesome! Thanks, I appreciate it!

@xaksis
Copy link
Owner

xaksis commented Jun 1, 2017

No problem! let me know if you have a problem using it.

@bbennett36
Copy link
Author

bbennett36 commented Jun 1, 2017 via email

@bbennett36
Copy link
Author

bbennett36 commented Jun 2, 2017

I got that working but it looked like there was an error in your sort method.

I had to change

  if (this.columns[this.sortColumn].field === 'date') {
                x = moment(x + '', this.columns[this.sortColumn].inputFormat);
              }

to

  if (this.columns[this.sortColumn].type === 'date') {
                x = moment(x + '', this.columns[this.sortColumn].inputFormat);
              }

Looks like you have it looking at the field name instead of the field type. My field name was "due_date" so it wasn't working at first and I had to go through and change that.

Other than that, it works great. Thanks again!

@xaksis
Copy link
Owner

xaksis commented Jun 2, 2017

whoops! good catch... 1 fix coming right up.

@xaksis xaksis reopened this Jun 2, 2017
@xaksis xaksis self-assigned this Jun 2, 2017
@xaksis
Copy link
Owner

xaksis commented Jun 2, 2017

v1.4.1

@xaksis xaksis closed this as completed Jun 2, 2017
@xaksis
Copy link
Owner

xaksis commented Jun 4, 2017

@bbennett36 I just switched out the date parsing/formatting library. Please let me know if all your use cases still work fine? Thank you!

@bbennett36
Copy link
Author

Are you able to use the 'defaultsortby' setting on a date field? Mine doesn''t seem to be working. The regular date sorting is still working perfect though.

cbonaudo referenced this issue in cbonaudo/vue-good-table Jun 3, 2020
…d-checkbox

Remove unused modifications on headerRow
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

No branches or pull requests

2 participants