0

I have a timestamp returned like this:

Fri Jun 30 2017 09:57:18 GMT+0100 (BST)

and I formatted it to look like this : Jun 30, Fri 2017 09:57

When it is sorted in the Griddle it is sorted alphabetically (apr,aug,dec,feb,jan,jul,jun,mar,may,nov,oct,sep) as it should but I really want to have them sorted according to months.

sortType: 'date' in metacolumns does not work.

return (<Griddle results={lRowData}
            columns={this.columns()}
            columnMetadata={this.columnMetadata()}
            initialSort="date"
            resultsPerPage={20}/>
        );
},
columns() {
    const lColumns = ['date'];
    return lColumns;
},
columnMetadata() {
    const lColumnMetadata = [{
        columnName: 'date',
        displayName: 'Date'
    }];
    return lColumnMetadata;
}

Is there a way to use some kind of indexed table like:

allMonths = ['Jan' , 'Feb', 'Mar', 'Apr', 'May',...., 'Dec'] where will be the one that helps on sorting them ?

Scriptable
  • 19,402
  • 5
  • 56
  • 72
Apsixos
  • 13
  • 4

1 Answers1

0

For Griddle v0.x, check out customCompareFn (docs), e.g.

const allMonths = ['Jan', 'Feb', ...];
const lColumnMetadata = [{
    columnName: 'date',
    customCompareFn: date => allMonths.indexOf(date.substring(0, 3)),
    displayName: 'Date'
}];
dahlbyk
  • 75,175
  • 8
  • 100
  • 122