It seems that column().search() does not trigger ajax search, Any suggestions

It seems that column().search() does not trigger ajax search, Any suggestions

MaWa69MaWa69 Posts: 5Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • MaWa69MaWa69 Posts: 5Questions: 1Answers: 0
    edited November 2022
    $('#search_filter').on('input', function () {
            datatable.column(0).search(
                $('#search_filter'.val())
            ).draw();
    

    This example of "external" input with search value works fine without ajax, but not with ajax.

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • MaWa69MaWa69 Posts: 5Questions: 1Answers: 0
    edited November 2022
    datatable = $('#table').DataTable({
            processing: true,
            serverSide: true,
            filter: true,
            searchDelay: 500,
            ajax: {
                url: "/profile/getdata",
                type: "POST",
                dataType: "json"
            },
            columns: [
                { data: "userName" },
                { data: "name" },
            ],
            select: true,
            searchPane: false,
            paging: false,
            error: function (xhr, error, code) {
                console.log(xhr, code);
            }
        });
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    edited November 2022

    $('#search_filter'.val())

    This doesn't look the the correct syntax. I think it should be $('#search_filter)'.val().

    Start troubleshooting by looking at the browser's console for errors and using the browser's network inspector to see the XHR request that is sent.

    If you still need help please post a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • MaWa69MaWa69 Posts: 5Questions: 1Answers: 0
    $('#search_filter').on('input', function () {
        datatable.column(0).search(
            $('#search_filter').val()
        ).draw();
    

    Sorry i was messing around with the code..

    This does not work either..

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You have serverSide enabled, so the filtering needs to be done by your server-side script. So as Kevin said, you'll need to debug that.

    Colin

  • MaWa69MaWa69 Posts: 5Questions: 1Answers: 0

    I found out that the search word appears in columns[0][search][value] in the ajax request.

    I cannot find documentation for searching searching vis search[value] programatically.

    Ofcause I can make a work around, but is there a correct way to search globally like the native search box;

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I cannot find documentation for searching searching vis search[value] programatically.

    The data sent to the server is documented here. How it is then processed will depend on whatever programming environment you are using at the server-side. We provide libraries for .NET, PHP and Node.js that you could use. For any others, or if you didn't want to use ours, the data that the server must send back is also documented on that page.

    Important to note that you should only use server-side processing if you have at least tens of thousands of rows in the table.

    Allan

Sign In or Register to comment.