Issues with column filtering using select inputs

Issues with column filtering using select inputs

TomBajzekTomBajzek Posts: 164Questions: 37Answers: 1

My DataTable uses client-side column filtering on several columns using select inputs. I've noticed that some of the select elements have two blank lines at the top. The top blank suppresses filtering on that column, as I would expect. The second blank line in the dropdown appears only for rows that have a NULL or otherwise empty field in that column, but selecting that one does not actually filter anything. This sometimes leads to user confusion. I have two questions:

  1. Is it possible to suppress the blank entry in the select element that appears in these cases?
  2. Is it possible to Initialize the Select element with a header entry, such as "Make a selection" so that the empty selector could be distinguished? (Whis would be useful only if the filter actually produced the rows with those empty columns.

I routinely use the second technique in select elements outside of DataTables, but I don't see how to make DataTables do that for me.

Please advise.

Thanks,
Tom

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Answer ✓

    You'd need to modify whatever code it is that you are using to generate the dropdowns to treat a null as the same as an empty string. Perhaps there is a strict type check in the code somewhere that could be changed to be a loose type check?

    Allan

  • TomBajzekTomBajzek Posts: 164Questions: 37Answers: 1

    Allan,

    Thanks to your suggestion, I solved this by checking that the length of the option value was > 0. I now wonder why I did not think of that before asking the question.

    Thanks very much,
    Tom

This discussion has been closed.