javascript - jquery Datatable: get order direction from moment-plugin -


i trying order direction of column moment-plugin (the column contains dates) sort '-'-entrys @ bottom of sorting (no matter if asc or desc) (see example below)

i have following code:

function($, moment) {   $.fn.datatable.moment = function ( format, locale ) {     var types = $.fn.datatable.ext.type;      // add type detection ('-' allowed)    types.detect.unshift( function ( d ) {       if(d === '-') {       return 'moment-'+format;      }        return moment( d, format, locale, true ).isvalid() ? 'moment-'+format : null;    });      // add sorting method - use integer sorting     types.order[ 'moment-'+format+'-pre' ] = function ( d ) {      return d === '-' || d === null ? infinity : parseint( moment( d.replace ? d.replace(/<.*?>/g, '') : d, format, locale, true ).format( 'x' ), 10 );    };   }; } 

when following, sorting doesn't work column @ all

    ...     // add sorting method - use integer sorting     types.order[ 'moment-'+format+'-asc' ] = function ( d ) {      //do    };     types.order[ 'moment-'+format+'-desc' ] = function ( d ) {      //do    }; 

are there other ways distinguish between asc/desc-ordering?

example trying (the '-' should @ bottom of sorting):

date (unsorted)         date (asc)                date (desc) 28.11.2014, 16:17       27.11.2014, 13:54         27.02.2015, 16:09 -                       28.11.2014, 16:17         28.11.2014, 16:17 27.11.2014, 13:54       27.02.2015, 16:09         27.11.2014, 13:54 -                       -                         - 27.02.2015, 16:09       -                         - 


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -