Closed spacebiscuit closed 5 years ago
Use the prefixSearch
option of the component for this:
https://github.com/ypnos-web/cakephp-datatables/blob/master/src/Controller/Component/DataTablesComponent.php#L25
Thanks - where should I add this? I tried in the options below my table:
$options = [
'ajax' => [
'url' => $this->Url->build() // current controller, action, params
],
'data' => $data,
'deferLoading' => $data->count(), // https://datatables.net/reference/option/deferLoading
'columns' => $columns, // set by the controller as a view variable
'order' => [0, 'asc'], // order by username
'prefixSearch' => true
];
It still only finds result if the left hand side matches the search string.
Sorry, I thought your question was already resolved. This is an option of the component right now. So you can set it with setConfig()
or in the component initialization (refer to CakePHP manual).
Perfect thank you it work :)
I have noticed that the global search for each table seems to work on right side LIKE operator meaning that it will only match the beginning of any row data.
Is it possible to use left and right side LIKE operator so that if my table row data is "this is a string", "string" would be matched where as currently it isn't.
Thanks