Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Sort N/A Updated dates as oldest, not newest
  • Loading branch information
zoffixznet committed May 17, 2016
1 parent 6714309 commit 2c79a16
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion public/js/main.js
Expand Up @@ -28,6 +28,15 @@ function setup_search_box_defocus() {
function setup_table() {
var el = $('#dists'), filter_container, filter, sort_order;

// Custom sorter for dates to sort N/A dates as oldest
$.fn.dataTable.ext.order['custom-na-date'] = function ( settings, col ) {
return this.api().column( col, {order:'index'} ).nodes().map(
function (td, i) {
var text = $(td).text();
return text == 'N/A' ? '0000-00-00' : text;
});
};

table_plugin = el.DataTable({
paging: false,
autoWidth: false,
Expand All @@ -40,7 +49,8 @@ function setup_table() {
},
{
targets: [ 6 ],
orderSequence: [ "desc", "asc" ]
orderSequence: [ "desc", "asc" ],
orderDataType: "custom-na-date"
}
]
});
Expand Down

0 comments on commit 2c79a16

Please sign in to comment.