Add custom parameter with .draw()

Add custom parameter with .draw()

postitiefpostitief Posts: 22Questions: 9Answers: 0
edited February 2017 in Free community support

Hello,

I'm using DataTables with serverSide processing. Now I want to send an extra parameter with the request so I can do some grouping of data. For the initial call, I can do this by adding data to the "ajax".

var dt = $('#products').DataTable({
  "processing": true,
  "serverSide": true,
  "ajax": {
    "url": "{{ route('product.data') }}",
    "data": function(d){
      d.grouping = 1;
    }
  },

This adds a parameter "grouping" with the value of "1".

No I have created multiple filters for the data, on a button click I'm redrawing the table to get the filtered products.

$("[data-search]").click(function () {
  // Setting dt.columns(x).search('')
  dt.draw();
});

How will I be able to modify the 'grouping' value just before calling dt.draw()?

This discussion has been closed.