Search code examples
jqueryajaxdatatablesyadcf

DataTables with yadcf plugin - how to override sent parameters


I'm using DataTable with yadcf plugin and I want to override send parameters to match my API on server.

For example: I have column Order, it's third column in columns array and I want to send parameter called orderSearch instead of columns[2].search.value.

How can I do this? How can I manipulate parameters?


Solution

  • Use ajax.data option to manipulate parameters sent to the server.

    For example:

    $('#example').DataTable({
      "processing": true,
      "serverSide": true,
      "ajax": {
        "url": "/script.php",
        "data": function(d){
            d.orderSearch = d.columns[2].search.value;
        }
      }
    });
    

    Also you can construct and return your own object which will not be merged with default DataTables response object. See this example for demonstration.