Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82029

Sort table with some criteria

$
0
0
JQuery's DataTables has very poor docs. So sorry for maybe trivial question.

I want for filter my table by some string on some column. Here is mine code:

 
var str = "days";
my_table.fnFilter(str, 9);


I expect to have only rows that contains "days" string at 9 column (counting from 0). But above code does not bring me result

I have tried to use this code with RexEx:

 
var regEx = "days"; 
my_table.fnFilter(regEx, 9, true);


this code:

 
var regEx = "^days$";
my_table.fnFilter(regEx, 9, true);


and this code:

 
var regEx = ".*days.*";
my_table.fnFilter(regEx, 9, true);


All without luck. I am sure my table has "101 days" string at 9 column. What am I doing wrong?

I have custom type for my column:
 jQuery.fn.dataTableExt.oSort['days-asc'] = function (a, b) {
    var x = parseInt((trim(a) == "") ? 0 : trim(a.replace(/days/, "")));
    var y = parseInt((trim(b) == "") ? 0 : trim(b.replace(/days/, "")));
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};

jQuery.fn.dataTableExt.oSort['days-desc'] = function (a, b) {
    var x = parseInt((trim(a) == "") ? 0 : trim(a.replace(/days/, "")));
    var y = parseInt((trim(b) == "") ? 0 : trim(b.replace(/days/, "")));
    return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};

Viewing all articles
Browse latest Browse all 82029

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>