How do I stop an API search showing in the search box?

How do I stop an API search showing in the search box?

bristolitdavebristolitdave Posts: 2Questions: 1Answers: 0

http://live.datatables.net/fejikude/1/
Debugger code (debug.datatables.net): None
Error messages shown: None
Description of problem:
Good Afternoon,
I've searched and driven myself crazy trying to find the answer. I used to use the fnFilter function which worked very nicely on individual columns - however the new Search API seems slightly harder? to use?

As per my test case above, when you click one of the radio buttons I do NOT want that value to appear in the search box - i.e. so that the user can then search for something else in the table alongside the filter I have applied.

Please can you tell me i'm missing something stupid?

Thank you!

Dave

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922
    Answer ✓

    You have the following:

                    var filteredData = table
                        .column(0)
                        .data()
                        .search($(this).val())
                        .draw();
    

    .column(0) .data() will return an API instance with the data in column 0. This is followed by .search($(this).val()) which will end up doing a global search instead of searching column 0. Remove .data() and the search will work as you expect. Here is your updated example:
    http://live.datatables.net/fejikude/2/edit

    Also note I change the Data 1 value to Ashton Cox so you can see that it works.

    Kevin

  • bristolitdavebristolitdave Posts: 2Questions: 1Answers: 0

    Thank you so much Kevin! That's exactly what I needed and it was something stupid ;-)

This discussion has been closed.