Changing server side params

Changing server side params

d0mokund0mokun Posts: 12Questions: 4Answers: 0

Hello all,

Are there any examples of how to manipulate SSP params as per https://datatables.net/manual/server-side ?

I am trying to use regex with SSP for searching and I don't understand the above page entirely.

Thanks
Dan.

Answers

  • loloskiloloski Posts: 46Questions: 5Answers: 1

    It's just an idea transform the request to POST method instead of GET and then stringify it then make appropriate changes.

    var table = $('#company').DataTable( {
    dom: "Bflrtip",
    responsive: true,
    colReorder: true,
    stateSave: true,
    "deferRender": true,
    "processing": true,
    "serverSide": true,
    "ajax": {
    "url": "/api/management/customer/listing2",
    "dataType": "json",
    "type": "POST",
    contentType: 'application/json',
    data: function ( data ) {
    return JSON.stringify( data );
    }

    then parse the body on the server side :)

  • d0mokund0mokun Posts: 12Questions: 4Answers: 0

    Thing is I've already got quite a complex setup for rendering the table and body. Literally the only thing giving issues is regex searching / filtering, which is just escaping me!

    Thanks

  • loloskiloloski Posts: 46Questions: 5Answers: 1

    Ok disregard what i've previously said, because I thought that you just want to change the params. hheheehe

  • d0mokund0mokun Posts: 12Questions: 4Answers: 0

    I managed to fix this one myself!

    I adjusted the AJAX code to send extra parameters to my SSP php file. I then rewrote the php file to allow for conditions using the complex ssp method if a value was sent, or simple if not.

            "ajax": {
                url: "table_builder.php",
                "data": function ( d ) {
                    return $.extend( {}, d, {
                        "cust_id": $( '.customer_search' ).val() ,
                    });
                }
            },
    

    'cust_id' being the condition value used to shape a search.

    Thanks
    Dan.

This discussion has been closed.