setting aoColumns options with variable columns

setting aoColumns options with variable columns

gibb3hgibb3h Posts: 7Questions: 0Answers: 0
edited November 2009 in General
Hello, i'm trying to set sType on my table to enable custom sorting, but my function is called in 2 ways, each of which will return a different number of columns. Therefore I cannot use a static array for aoColumns, how can I get around this?

thanks in advance

Replies

  • gibb3hgibb3h Posts: 7Questions: 0Answers: 0
    I've had a better thought, i'm using the formatted numbers sorting plugin: -

    jQuery.fn.dataTableExt.oSort['formatted-num-desc'] = function(x,y){
    x = x.replace(/[^\d\-\.\/]/g,'');
    y = y.replace(/[^\d\-\.\/]/g,'');
    if(x.indexOf('/')>=0)x = eval(x);
    if(y.indexOf('/')>=0)y = eval(y);
    return x/1 - y/1;
    }
    jQuery.fn.dataTableExt.oSort['formatted-num-asc'] = function(x,y){
    x = x.replace(/[^\d\-\.\/]/g,'');
    y = y.replace(/[^\d\-\.\/]/g,'');
    if(x.indexOf('/')>=0)x = eval(x);
    if(y.indexOf('/')>=0)y = eval(y);
    return y/1 - x/1;
    }

    how can I set a new auto type detection for this? I have seen the one for comma as decimal point, but not for the plugin.
  • gibb3hgibb3h Posts: 7Questions: 0Answers: 0
    never mind, got it :D

    jQuery.fn.dataTableExt.aTypes.push(
    function ( sData )
    {
    var sValidChars = "0123456789-,";
    var Char;
    var bDecimal = false;

    /* Check the numeric part */
    for ( i=0 ; i
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi gibb3h,

    I like questions like that ;-)

    Good to hear you got it sorted,
    Allan
This discussion has been closed.