Skip to content

Commit

Permalink
fix date sort bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xaksis committed Sep 14, 2017
1 parent 92730c8 commit d7fcb55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
25 changes: 10 additions & 15 deletions dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,19 @@
field: 'age',
type: 'number',
},
{
label: 'Created at',
field: 'creationDateF',
type: 'date',
inputFormat: 'DD-MM-YYYY HH:mm:ss', //e.g. 07-09-2017 19:16:25
outputFormat: 'DD-MM-YYYY HH:mm:ss'
}
],
rows: [
{name: "John", age: "20"},
{name: "Jane", age: "24"},
{name: "Susan", age: "16"},
{name: "Chris", age: "55"},
{name: "Dan", age: "40"},
{name: "Cankut", age: "20"},
{name: "Aylin", age: "24"},
{name: "Adam", age: "16"},
{name: "Zoe", age: "55"},
{name: "Niraj", age: "40"},
{name: "Abina", age: "20"},
{name: "Tiago", age: "20"},
{name: "John", age: "20", creationDateF: "07-09-2017 19:16:25"},
{name: "Jane", age: "24", creationDateF: "09-10-2017 19:16:25"},
],
};
},
};
</script>


</script>
2 changes: 1 addition & 1 deletion src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ import {format, parse, compareAsc} from 'date-fns/esm'
//take care of dates too.
if (this.columns[this.sortColumn].type === 'date') {
d = parse(d + '', this.columns[this.sortColumn].inputFormat);
d = parse(d + '', this.columns[this.sortColumn].inputFormat, new Date());
} else if (typeof(d) === 'string') {
d = d.toLowerCase();
if (this.columns[this.sortColumn].type == 'number')
Expand Down

0 comments on commit d7fcb55

Please sign in to comment.