Bardr
Bardr

Reputation: 2559

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?

Upvotes: 1

Views: 299

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58900

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.

Upvotes: 2

Related Questions