Bug in adding row after filtering

Bug in adding row after filtering

jacksumitjacksumit Posts: 4Questions: 0Answers: 0
edited May 2009 in Bug reports
Hi Allan

I am extensively using datatable in my project and for that i am also going through your code. I would like to congratulate you for making such a wonderful plugin.

One more bug that I came around

Call fnFilter with bEscapeRegex set to 0. that means i will call like


then add some row using fnAddData(array) and check what happens. no record will be shown in table even not those which satisfies the above search criteria.

Reason for bug
fnAddData calls _fnReDraw which calls _fnFilterComplete

In _fnFilterComplte we call _fnFilterColumn. In this call we use oSettings.asPreSearchCols[i] as our sInput but we neglected what type of search it was (bEscapeRegex=0 or 1).

so it calls _fnFilterColum(oSettings,("^(sumit)|^(amit)",1,true); for i=1

Solution that I implemented
Store type of search in an array in oSettings (oSettings.asPreSearchColsType[i]) when fnFilter is called similar to storing oSettings.asPreSearchCols[i].

Use this oSettings.asPreSearchColsType[i] in call to _fnFilterColum.

Same case may arise for call to _fnFilter in _fnFilterComplete, so we also need to store type of oSettings.sPreviousSearch.


  • allanallan Posts: 56,819Questions: 1Answers: 9,029 Site admin
    Good catch! Thanks very much for the detailed bug report. I'll look at including your fix in the next release version of DataTables.

This discussion has been closed.