chg: [component:CRUD] Pass searched value to the view and allow searching by hitting <enter>
parent
62426e0160
commit
ba65c60838
|
@ -341,6 +341,7 @@ class CRUDComponent extends Component
|
|||
{
|
||||
$queryConditions = [];
|
||||
if (!empty($params['quickFilter']) && !empty($quickFilterFields)) {
|
||||
$this->Controller->set('quickFilterValue', $params['quickFilter']);
|
||||
foreach ($quickFilterFields as $filterField) {
|
||||
$likeCondition = false;
|
||||
if (is_array($filterField)) {
|
||||
|
@ -352,6 +353,8 @@ class CRUDComponent extends Component
|
|||
}
|
||||
}
|
||||
$query->where(['OR' => $queryConditions]);
|
||||
} else {
|
||||
$this->Controller->set('quickFilterValue', '');
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ echo $this->element('genericElements/IndexTable/index_table', [
|
|||
'button' => __('Filter'),
|
||||
'placeholder' => __('Enter value to search'),
|
||||
'data' => '',
|
||||
'value' => $quickFilterValue,
|
||||
'searchKey' => 'value'
|
||||
]
|
||||
]
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
var url = '/' + controller + '/' + action + additionalUrlParams + '?quickFilter=' + encodeURIComponent($('#quickFilterField-<?= h($tableRandomValue) ?>').val());
|
||||
executePagination(randomValue, url);
|
||||
});
|
||||
$('#quickFilterField').on('keypress', function (e) {
|
||||
$('#quickFilterField-' + randomValue).on('keypress', function (e) {
|
||||
if(e.which === 13) {
|
||||
var url = '/' + controller + '/' + action + additionalUrlParams + '?quickFilter=' + encodeURIComponent($('#quickFilterField-<?= h($tableRandomValue) ?>').val());
|
||||
executePagination(randomValue, url);
|
||||
|
|
Loading…
Reference in New Issue