How to sort on input fields on dates with special format , using moment.js
How to sort on input fields on dates with special format , using moment.js
I am trying to sort a column with dates in a text input. I am loading
- jquery
- datatables
- moment.js
-datetime-moment.js
I then initialize moment with this for my date format (day-month-shortYear);
$.fn.dataTable.moment( 'D-M-YY' );
I am trying to use this example: http://datatables.net/plug-ins/sorting/custom-data-source/dom-text
Then I define the dom element:
/* Create an array with the values of all the input boxes in a column */
$.fn.dataTable.ext.order['dom-text-numeric'] = function ( settings, col )
{
return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
return $('input', td).val() * 1;
} );
}
Then I define the date field no. 3
$('#example').dataTable( {
"columns": [
null,
null,
{ "orderDataType":"dom-text", type: 'text' }
]
} );
I even tried this:
{ "orderDataType":"dom-text", type: 'date' }
Is there a valid value "dom-date" ?
What am I doing wrong?