简体   繁体   中英

jQuery DataTables - UK date column sorting

I'm using the DataTable plugin on one of my project - and the date-sorting is driving me crazy! ;)

Basically, I have tables with various number of columns (between 2 and 8 columns).
The date column is always the first column - I want to set UK date format sorting on first column without knowing the exact number of columns.

According to the doc here: http://datatables.net/usage/columns the following 2 examples should work identical:

Example #1. ( live demo: http://jsfiddle.net/MrTest/yM24R/33/ )

       "aoColumnDefs": {
            "aTargets": [0] ,
            "sType": "uk_date"
        }

Example #2. ( live demo: http://jsfiddle.net/MrTest/yM24R/ ) - but with this way you must know the exact number of columns.

      "aoColumns": [
           {
            "sType": "uk_date"},
            null,
            null,
            null

            ]

As you can see the second example works fine and sort the dates correctly, but the first one does not work at all.

Have anyone of you have some experience with the plugin or the problem? Any help much appreciated.

You mixed up curly brackets with [ ]

"aoColumnDefs" : [
   {"aTargets" : [0] , "sType" : "uk_date"}
]

如果列是3,则在顺序数组中提及2

"order": [[ 2, "desc" ]]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM