-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds custom datatable sort so blank fields sort at bottom.
- Loading branch information
1 parent
750de27
commit 2ada1a1
Showing
1 changed file
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,26 @@ | ||
|
||
$(document).on('ready page:load', function () { | ||
$('table').DataTable(); | ||
jQuery.extend( jQuery.fn.dataTableExt.oSort, { | ||
"non-empty-string-asc": function (str1, str2) { | ||
if(str1 == "") | ||
return 1; | ||
if(str2 == "") | ||
return -1; | ||
return ((str1 < str2) ? -1 : ((str1 > str2) ? 1 : 0)); | ||
}, | ||
|
||
"non-empty-string-desc": function (str1, str2) { | ||
if(str1 == "") | ||
return 1; | ||
if(str2 == "") | ||
return -1; | ||
return ((str1 < str2) ? 1 : ((str1 > str2) ? -1 : 0)); | ||
} | ||
} ); | ||
$('table').DataTable({ | ||
columnDefs: [ | ||
{type: 'non-empty-string', targets: 0} // define 'name' column as non-empty-string type | ||
] | ||
}); | ||
$("[data-toggle='tooltip']").tooltip(); | ||
}); |