forked from fheider/cakephp-datatables
-
Notifications
You must be signed in to change notification settings - Fork 24
Adding extra ajax parameters
shuadoc edited this page Feb 26, 2020
·
1 revision
You'll need to use a custom Callback-functions to send javascript from PHP:
$options = [
'ajax' => [
'url' => $this->Url->build('...'),
'data' => $this->DataTables->callback("function(d) {
d.customParameter = $('#myElement').val();
}"),
],
....
(above code would be in a view)
You can append additional where clauses to the end of the find
result, and then will need to re-calculate the result count:
$data = $this->DataTables->find('table', 'all', [], $columns);
$data->where(['table.column' => $this->request->getQuery()['customParameter']]);
//Re-calculate count to display correct number of pages:
$this->viewVars['recordsFiltered'] = $data->count();