SearchBuilder server-side support ( Java)

SearchBuilder server-side support ( Java)

KarthikGuttapudiKarthikGuttapudi Posts: 5Questions: 1Answers: 0

Hi All,

We are using server-side processing (Java), and cannot find how to get the SearchBuilder request details. Currently we are using "data" function to modify the data sent to server-side code (Java), can we get the SearchBuilder request in the "data" function so that we can send it to server-side.

    "ajax": {
                    "url": ....,,
                    "contentType": "application/json",
                    "type": "POST",
                    "headers": .....,
                    "dataType": "json",
                    "data": function ( d ) {
                      let request = requestData;
                      request.dataTablerequest = d;
                      return JSON.stringify( request );
                    },

Answers

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

    The client should be sending the data to the server automatically, see this example demonstrating that. Here, the backend is JS, so that wouldn't be of any use to you, but you should be getting the data still. Can you see if that helps, please, and if not, can you link to your page so we can take a look,

    Colin

  • KarthikGuttapudiKarthikGuttapudi Posts: 5Questions: 1Answers: 0

    Thank you for the reply Colin. Yes I looked at that example earlier, in the example I see that the search builder criteria is sent in the request. In my case whenever I add a condition (using SearchBuilder) the ajax call (to server) get triggered but I do not see the search builder criteria getting sent in the request body. Will setup a test page, I am not sure how to setup the server-side though as I cannot expose my server code/API in the test page.

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

    I fear we won't be able to help you with the Java aspect of this. If the information is being sent to the server, then how to get it in the Java program - I'm afraid we don't know as we don't provide or support Java libraries. You must be getting other information from the request such as the ordering information though - presumably you'd be able to use the same sort of method.

    Allan

  • KarthikGuttapudiKarthikGuttapudi Posts: 5Questions: 1Answers: 0

    Hi Allan, may be I was not clear, I do not see the SearchBuilder criteria being sent in the request by DataTables.

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

    One thing to note is that you need to have enabled serverSide for that data to be sent, as it's part of the server-side protocol,

    Colin

  • KarthikGuttapudiKarthikGuttapudi Posts: 5Questions: 1Answers: 0

    Yes Colin, I am using the serverSide but still the search builder criteria is getting sent in request. Found a way, I had to manually send the search builder details like this, to send them in the request to the server

        let requestData = ....
    
        dt = $('#example').DataTable( {
            .....
            .....
                "ajax": {
                        "url": .....,
                        "contentType": "application/json",
                        "type": "POST",
                        "headers": ....,
                        ...
                        "data": function ( d ) {
                          let request = requestData;
                          request.dataTablerequest = d;
                          //check if dt is available( not available on load), if present then
                          request.dataTablerequest.searchBuilderRequest = dt.searchBuilder.getDetails(true); //this works
    
                          return JSON.stringify( request );
                        },
                        ......
                    },
                    "serverSide": true,
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    I do not see the SearchBuilder criteria being sent in the request by DataTables.

    but then you said:

    the search builder criteria is getting sent in request.

    I'm not clear on which it is since they appear to be opposite statements? Is it is only being sent if you use the getDetails function manully?

    Allan

  • KarthikGuttapudiKarthikGuttapudi Posts: 5Questions: 1Answers: 0
    edited April 2022

    Hi Allan, my bad, it is a typo, issue is solved now after doing it like mentioned above. Yes criteria is only getting sent If I use the getDetails manually

  • dhinu2001dhinu2001 Posts: 6Questions: 2Answers: 0

    Hello Karthik Guttapudi, I saw your previous conversation, and I need assistance implementing server side processing in Java. Could you provide any of the resources you utilized or explain how you accomplished it in Java?

Sign In or Register to comment.