fnFilter does not work correct?

fnFilter does not work correct?

hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

Hello
strange behavior with filter function.
I try to make a filter "Not showing" (reverse filtering)
A table with column 4 (Status) and 8 rows from a database
Row 3 has the Word / value "Abschluss"
Row 5 has the Word / value "Betrieb"
Other rows has other values

for testing I did this:

$('#filter_rating').click(function() {
oProjectTable.fnFilter('[^Abschluss]$', 3, true, false);
});

The curios result is that row 3 is gone away (hidden) as expected but also row 5 with value "Betrieb"

Why this?
What is wrong with the Regex?

best regards
hawk

Replies

  • ignignoktignignokt Posts: 146Questions: 4Answers: 39
    edited November 2014

    I'm not familiar with using regex with fnFilter, but try ^(Abschluss)$ instead of [^Abschluss]$

    [ ] are explicit characters to match while ( ) contains a logical grouping of the expression.

  • allanallan Posts: 61,934Questions: 1Answers: 10,155 Site admin

    You shouldn't even need the parenthesis - ^Abschluss$ will do with column().search() or the older fnFilter method.

    Allan

  • hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

    @allan
    I had the fnFilter method as you can see in my post?

    $('#filter_rating').click(function() { oProjectTable.fnFilter('[^Abschluss]$', 3, true, false); });

    But the regex I am using was wrong.

    hawk

  • allanallan Posts: 61,934Questions: 1Answers: 10,155 Site admin

    Yup I saw it. As @ignignokt noted the regex was wrong, and as I noted you don't need the parenthesis in this particular case.

    Allan

This discussion has been closed.