(Legacy) Custom filter type auto detect?
(Legacy) Custom filter type auto detect?
PeterDefendo
Posts: 3Questions: 1Answers: 0
We are using 1.9.4 (we are going to upgrade soon but not right now).
I have the following code:
(function(){
var spacenumRegex = /\W/g;
var removenbspRegex = /\ \;/g;
function format(sData) {
return sData.replace(removenbspRegex, "").replace(spacenumRegex, "");
}
$.fn.dataTableExt.ofnSearch["spacenumber"] = function (sData) {
return format(sData);
}
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"spacenumber-pre": function (sData) {
return parseInt(format(sData));
},
"spacenumber-asc": function (a, b) {
return a - b;
},
"spacenumber-desc": function (a, b) {
return b - a;
}
});
jQuery.fn.dataTableExt.aTypes.unshift(
function (sData) {
if ($.isNumeric(format(sData))) {
return "spacenumber";
}
return null;
}
);
})();
It allows me to sort number correctly even when there is a space in them, example 10 000
and 100
.
It correctly detects the format for sorting but the ofnSearch
function is never called what am i missing?
This discussion has been closed.
Answers
Realized that i should have posted in the 1.9 part of the forum.
I found no way to move or delete my post.
The expected out should be that if i search for
5000
it should match the row that contains5 000