Wet-boew: Using data-wb-tables='{"order": [ 0, "desc" ]}' for a column that has date

Created on 9 Mar 2019  路  4Comments  路  Source: wet-boew/wet-boew

Hello,
I am trying to sort by default my table with a column that contains date in format like "August 27th, 2010,
at 03:44". Is there a way to do so or should I change date format?

Thank you in advance

Table enhancement Question Resolved

All 4 comments

According to DataTables you have to make use of the HTML5 data-* attributes.

Basically the html has to look like <td data-order="1344211200">Mon 6th Aug 12</td>.

You can read more here: https://www.datatables.net/examples/advanced_init/html5-data-attributes.html.

And read the DataTables page about orthogonal data for this particular date problem: https://datatables.net/manual/data/orthogonal-data. Specifically, look at the data-sort and data-order attributes.

Thank you very much for your answers. I will check them out. I assume the data-order will contain the timestamp right?

I assume the data-order will contain the timestamp right?

Yes if your timestamp is a number. You can also use the Unix time which is the number of millisecond since January 1, 1970

Was this page helpful?
0 / 5 - 0 ratings