Ui-table date sort

Anyone know of a neat trick to get a ui-table to do sorting by date, rather than standard numeric sort?

Thanks

Hmm not tested but should be possible:

As you can configure ui-table using ui_config there is certainly a way.
Is your data a string or a unix timestamp?

Some reading for weekend, thank you. :stuck_out_tongue_winking_eye:

String

A quick jump start .... This should handle your Sting - depending moment.js defined input / output format

{
    "tabulator": {
        "columns": [
            {
                "title": "Time",
                "field": "timestamp",
                "width": 100,
                "formatter": "datetime",
                "formatterParams": {
                    "inputFormat": "YYYY-MM-DD HH:mm:ss.SSS",
                    "outputFormat": "HH:mm:ss",
                    "invalidPlaceholder": "(invalid time)"
                }
            }
        ]
   }
}

Thank you. Appreciate it.

So just to close this out. What worked for me (bearing in mind this was date only, no time) was -

{
    "tabulator": {
        "columns": [
            {
                "sorterParams": {
                    "format": "DD/MM/YY"
                },
                "title": "Date",
                "field": "input_date",
                "width": 100,
                "sorter": "date"
                }
            }
        ]
   }
}

@Christian-Me thanks for showing me the way! :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.