I am using angular datatables in my application. So far, everything is working fine, except when I try to add custom sorting.
I have a dataset that returns a hyphen, "-" if there is no data. Here is my sorting ::
$.fn.dataTableExt.oSort['nullable-asc'] = function(a,b) { if (a == '-') return 1; else if (b == '-') return -1; else { var ia = parseInt(a); var ib = parseInt(b); return (ia<ib) ? -1 : ((ia > ib) ? 1 : 0); } } $.fn.dataTableExt.oSort['nullable-desc'] = function(a,b) { console.log(a,b) if (a == '-') return 1; else if (b == '-') return -1; else { var ia = parseInt(a); var ib = parseInt(b); return (ia>ib) ? -1 : ((ia < ib) ? 1 : 0); } } ..start controller... vm.dtColumnDefs = [ DTColumnDefBuilder.newColumnDef(0).notSortable().withClass('hidden-print') DTColumnDefBuilder.newColumnDef(1).withClass('td-fieldname'),
This works great when trying to use a standard table, but does not work with the angular app. When I click on the table heading to sort, nothing happens. Console.log above gives empty values. Is there a way to use custom sorting using the angular directive?
Ortal source share