Server-side - Global Search - the search parameter received by the server-side is 'null'.

Server-side - Global Search - the search parameter received by the server-side is 'null'.

GlyndwrGlyndwr Posts: 117Questions: 32Answers: 0

http://live.datatables.net/dexivuxu/1/edit

I am trying to convert an existing working DataTables to server-side. I have most of it working. However, I am stuck on filtering and ordering. First filtering. Each time I enter a value in "Search:" (the global search field) the server-side is called; however, the 'search' value received on the server-side is 'null'. On the server-side I use the following java code:

    //DataTables Server-side variables
    String draw = request.getParameter("draw"); //Counter to ensure correct order
    int start = Integer.parseInt(request.getParameter("start"));//Number of rows to return
    int length = Integer.parseInt(request.getParameter("length"));//Number of rows to return
    String search = request.getParameter("search"); // Global search value

The variables 'draw', 'start' and 'length' are correct when I display them; however, 'search' contains null.

I obtained the parameter (search) to use from: https://datatables.net/manual/server-side

Kind regards,

Glyn

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,150Questions: 26Answers: 4,736
    Answer ✓

    String search = request.getParameter("search");

    The parameter isn't just 'search'. There are two parameters; one is search[value] and the other is search[regex].

    Kevin

  • GlyndwrGlyndwr Posts: 117Questions: 32Answers: 0

    Thanks Kevin. I am not using search[regex] at the moment; however, just in case, how is it set to 'true' (it is currently 'false') please?

  • kthorngrenkthorngren Posts: 20,150Questions: 26Answers: 4,736
    edited September 2020

    Use search.regex. Or set the option using the search() API.

    Kevin

  • GlyndwrGlyndwr Posts: 117Questions: 32Answers: 0

    Thank you. So:

    $('#example').dataTable( {
    "search": {
    "regex": true
    }
    } );

This discussion has been closed.