Searching Empty String in Column

Searching Empty String in Column

shivampawshivampaw Posts: 1Questions: 1Answers: 0

Hi,

I am trying to search for an empty string like this:

oTable.columns([clientfirst, clientsecond, clientthird]).search( '^$', true, false ).draw();

Where clientfirst, clientsecond, clientthird are indexes.

However the table is showing all rows.

Is this because I need it to make sure all the rows are blank and not just one of them?

In the table example I have clientfirst and clientthird blank but clientsecond isn't.

How can I fix this?

Thanks

Answers

  • stevevancestevevance Posts: 58Questions: 6Answers: 1

    I am also looking for a way to search for cells that are empty.

  • kthorngrenkthorngren Posts: 20,331Questions: 26Answers: 4,774

    oTable.columns([clientfirst, clientsecond, clientthird]).search( '^$', true, false ).draw();

    The problem with this search is that Datatables performs an and search through each column of the row. If only one column were listed above then search would work. However if you want to search the full table then a custom search API is needed to execute the search using or.

    Here is an example:
    http://live.datatables.net/xawixeha/1/edit

    Setting blankCells to false will return all rows. Setting it true will return rows with blank cells. The table has 6 columns. I put one blank in each column on 6 different rows. When blankCells is true the table will display those 6 rows.

    Kevin

This discussion has been closed.