DataTable search

DataTable search

arnolddd97arnolddd97 Posts: 8Questions: 3Answers: 0
edited May 2019 in Free community support

I just want to search for "0", but but also looking for "10" and "90"

<select id="status-filter"> ' +
                '<option value="-1"> Összes</option> ' +
                '<option value="0">Beérkezés létrehozva</option> ' +
                '<option value="1">Beérkezett</option> ' +
                '<option value="2">Vámolás alatt</option> ' +
                '<option value="3">Vámolás készen</option> ' +
                '<option value="4">Cimke nyomtatva</option> ' +
                '<option value="5">Beolvasás alatt</option> ' +
                '<option value="10">Áruk beérkeztekt</option> ' +
                '<option value="90">Átvételi elismervény nyomtatva</option> ' +
                '<option value="999">Szállítási Kivétel</option> ' +
                '</select>');
$("body").on("change","#status-filter",function () {
        if($(this).val() == "-1"){
            table
                .column(4)
                .search("")
                .draw();
        }else {
            table
                .column(4)
                .search($(this).val())
                .draw();
        }

    });

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,231Questions: 1Answers: 2,594

    Hi @arnolddd97 ,

    You'll need to use enable regular expressions with column().search(), so something like

                table
                    .column(4)
                    .search('^' + $(this).val() + '$', true, false)
                    .draw();
    

    Cheers,

    Colin

  • arnolddd97arnolddd97 Posts: 8Questions: 3Answers: 0

    Unfortunately does not work.



  • kthorngrenkthorngren Posts: 20,896Questions: 26Answers: 4,870
    Answer ✓

    It looks like your code should be working. So I built a simple test case based on your code and it does work:
    http://live.datatables.net/remesini/1/edit

    In order to help we will need a link to your page or a test case replicating the issue. Maybe you can update my test case to show your issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • arnolddd97arnolddd97 Posts: 8Questions: 3Answers: 0

    i want status = 0 ---> on display all 0 status

    Now status is 0 ---> on display all 0 and 10 and 90 status, because like is 0

  • arnolddd97arnolddd97 Posts: 8Questions: 3Answers: 0

    Thanks for te help.

  • colincolin Posts: 15,231Questions: 1Answers: 2,594

    Hi @arnolddd97 ,

    As Kevin said, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.