(Legacy) Custom filter type auto detect?

(Legacy) Custom filter type auto detect?

PeterDefendoPeterDefendo Posts: 3Questions: 1Answers: 0
edited March 2016 in Free community support

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 = /\&nbsp\;/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?

Example: http://live.datatables.net/meyozumu/1/

Answers

  • PeterDefendoPeterDefendo Posts: 3Questions: 1Answers: 0

    Realized that i should have posted in the 1.9 part of the forum.
    I found no way to move or delete my post.

  • PeterDefendoPeterDefendo Posts: 3Questions: 1Answers: 0

    The expected out should be that if i search for 5000 it should match the row that contains 5 000

This discussion has been closed.