This repository was archived by the owner on May 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
datetime
Karl edited this page Jul 11, 2017
·
19 revisions
Vanilla DataTables can utilise the MomentJS library for parsing datatime strings for easier column sorting.
There are two ways to sort columns based on datatime strings.
Define a data-type attribute on the headings and set the value to date. If the datatime string is in a format that can not be sort easily by standard methods, you must set the data-format attribute and set it's value to the format that is expected.
<table>
<th data-type="data" data=format="DD/MM/YYYY"></th>
<th data-type="data" data=format="MM/DD/YY"></th>
...
</table>The date and format strings can also be defined in the options using the columns property:
// Select the first column and apply the `date` type and `format` to it
var datatable = new DataTable("#myTable", {
columns: [
{
select: 0,
type: "date",
format: "DD/MM/YYYY"
}
]
});
// Select the first, third and fourth columns and apply the `date` type and `format` to them
var datatable = new DataTable("#myTable", {
columns: [
{
select: [0,2,3],
type: "date",
format: "MM/DD/YY"
}
]
});- datatable.init
- datatable.refresh
- datatable.update
- datatable.page
- datatable.sort
- datatable.perpage
- datatable.search
- perPage
- perPageSelect
- nextPrev
- prevText
- nextText
- firstLast
- firstText
- lastText
- searchable
- sortable
- truncatePager
- fixedColumns
- fixedHeight
- columns
- data
- ajax
- labels
- layout
- header
- footer
- table
- head DEPRECATED
- body DEPRECATED
- foot DEPRECATED
- wrapper
- container
- pagers
- headings
- options DEPRECATED
- initialized
- isIE DEPRECATED
- data
- activeRows DEPRECATED
- dataIndex
- pages
- hasRows
- hasHeadings
- currentPage
- totalPages
- onFirstPage
- onLastPage
- searching
- searchData