Skip to content

Commit 63a022a

Browse files
committed
Fix date parsing when using DateFilter
1 parent 182086d commit 63a022a

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

examples/js/column-filter/all-filters.js

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ function enumFormatter(cell, row, enumObject) {
3636
}
3737

3838
function dateFormatter(cell, row) {
39+
if (typeof cell !== 'object') {
40+
cell = new Date(cell);
41+
}
42+
3943
return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`;
4044
}
4145

examples/js/column-filter/date-filter-programmatically.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function addProducts(quantity) {
2323
addProducts(5);
2424

2525
function dateFormatter(cell, row) {
26+
if (typeof cell !== 'object') {
27+
cell = new Date(cell);
28+
}
29+
2630
return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`;
2731
}
2832

examples/js/column-filter/date-filter-with-default-value.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function addProducts(quantity) {
2323
addProducts(5);
2424

2525
function dateFormatter(cell, row) {
26+
if (typeof cell !== 'object') {
27+
cell = new Date(cell);
28+
}
29+
2630
return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`;
2731
}
2832

examples/js/column-filter/date-filter.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function addProducts(quantity) {
2323
addProducts(5);
2424

2525
function dateFormatter(cell, row) {
26+
if (typeof cell !== 'object') {
27+
cell = new Date(cell);
28+
}
29+
2630
return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`;
2731
}
2832

src/store/TableDataStore.js

+4
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ export class TableDataStore {
322322
const filterMonth = filterVal.getMonth();
323323
const filterYear = filterVal.getFullYear();
324324

325+
if (typeof targetVal !== 'object') {
326+
targetVal = new Date(targetVal);
327+
}
328+
325329
const targetDate = targetVal.getDate();
326330
const targetMonth = targetVal.getMonth();
327331
const targetYear = targetVal.getFullYear();

0 commit comments

Comments
 (0)