I am working on the exercise in the documentation. I would like the date to be sorted (asc) by default when data is first loaded into the table.
In other words : when the user load the table, I would like him/her to see the youngest on top of the table (sorting by Date of Birth).
I have read all the documentation but didn't find the clue. I tried initialSort
as well but wasn't able to fix it.
Any help ? Thanks you for your time
initialSort
should work. Have you included the moment.js library, as documentation says?
In this example from my code, it works:
const dateFormatter = {
inputFormat:"YYYY-MM-DD HH:mm:ss",
outputFormat:"DD/MM/YYYY HH:mm:ss",
invalidPlaceholder:"(invalid date)",
}
var myTable = new Tabulator("#table", {
columns:[
{title:"Date", field: DATE_KEY, formatter:"datetime", formatterParams: dateFormatter },
{title:"Total cases", field: CASES_KEY},
],
initialSort:[
{column:DATE_KEY, dir:"desc"}, //sort by this first
]
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With