Filtering blank values in columns that have an input

Filtering blank values in columns that have an input

ghendricghendric Posts: 13Questions: 5Answers: 0
edited October 2021 in DataTables

Test case: https://codepen.io/george-hendrickson/pen/bGrgOzJ

I set up the datatable to use a dropdown for each column to search data. Within a couple of columns, I put a text box for user input. The search works fine if there is already a value in the text boxes but it can't find rows where the value is blank within the text box. This is the code in the javascript file that gets executed if a user selects a blank value from the dropdown.

            // **********************************************
            // This is not finding blank values in the column if there is an input there
            // **********************************************
            column.search('^$', true, false).draw();

I have not been able to find any solutions for this. Like I said, the search works fine if there is a value in the text box already, it just doesn't work correctly with blank values. Search works fine if the value is blank and there is no input within the cell.

Any help is greatly appreciated.

Thanks,
George

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 14,303Questions: 1Answers: 2,431
    Answer ✓

    This example from this thread should help - it's demonstrating just that.

    Colin

  • ghendricghendric Posts: 13Questions: 5Answers: 0
    edited October 2021

    searching for things with the Search text box works fine for rows that are not blank. the issue i'm having is with the column dropdown performing a search for blank values that exist in the column as indicated in the test case i provided. Look at the Fax column in the test case. The example that you provided doesn't seem to work for me. Perhaps I'm doing something incorrectly with it.

  • ghendricghendric Posts: 13Questions: 5Answers: 0

    Nevermind, it is working. I had changed some code testing something and i forget to change it back.. lol.. this is working.. thanks for the help!

Sign In or Register to comment.