fnFilter does not work if one column is empty (bug or feature? )

fnFilter does not work if one column is empty (bug or feature? )

hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

Hello
I have implemented a Filter function with fnFilter and Regex to hide DataTable rows which are in the filter.
It works fine but I have seen a strange behavior if a row has a column which is empty.

myTable.fnFilter('^(?!(?:' + selectedRatingRegexValues + ')$).+$', 5, true, false);

This Filter should work for the 6. column. But if the coulmn 5 is empty the filter does not work for column 6 in this row.

Is there a workaround for that behavior?

regards
hawk

Answers

  • hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

    no ideas?
    Is this a normal behavior with an empty column?

  • hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

    Hello,
    I do not know if this is the best or correct solution.
    I made a render function for columns which can be empty with HTML  
    So the columns seems to be still empty but the fnFilter function works now also for this columns

    "render": function ( data, type, row ) {
    if(data){
    return data;
    }
    else{
    return ' ';
    }

  • hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

    I mean HTML -& n b s p ;-
    (nonbreaking space)

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Sounds like you might be using an old version of DataTables. There was a release or two which had this bug (can't remember which exactly, was around 1.10.1/2 I think). Try the latest release and see if that helps.

    Allan

  • hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

    Allen, thanks a lot for this hint.
    This was the trick. I had version 1.10.1. Now with the newest version it runs also without the render function.

This discussion has been closed.