What steps will reproduce the problem?
- Create GridView with ActionColumn and filters/sorting features.
- Select some filters and sort some columns
- Click button in ActionColumn
- As result - all filters reseted
What is the expected result?
Filters/Sorters should be saved/restored after clicking buttons in action column.
What do you get instead?
All filters reseted, after clicking actionColumn button.
As temporary solution, it's possible use closure in action column
[
'class' => '\yii\grid\ActionColumn',
'urlCreator' => function ($action, $model, $key, $index) {
$request = \Yii::$app->getRequest();
$paramsFromRequest = $request instanceof \yii\web\Request ? $request->getQueryParams() : [];
$params = is_array($key) ? $key : ['id' => (string) $key];
$params[0] = \Yii::$app->controller->id . '/' . $action;
return \Yii::$app->urlManager->createUrl(array_merge($paramsFromRequest, $params));
]
Additional info
Method createUrl() also used in Pagination.php, Sort.php, but in these classes for creating Url is used current parameters from request, so we don't have problems with resetting filters/sorting.
But for action column we should use slightly different solution because, creteUrl will be executed for each row/column, so we need params 'caching' (may be in GridView widget) from request for avoiding $paramsFromRequest = $request instanceof \yii\web\Request ? $request->getQueryParams() : []; calculating in each row.
| Q |
A |
| Yii version |
2.0.7-372-g5921865 |
| PHP version |
PHP 5.6.11 |
| Operating system |
Ubuntu |
What steps will reproduce the problem?
What is the expected result?
Filters/Sorters should be saved/restored after clicking buttons in action column.
What do you get instead?
All filters reseted, after clicking actionColumn button.
As temporary solution, it's possible use closure in action column
Additional info
Method
createUrl()also used inPagination.php,Sort.php, but in these classes for creating Url is used current parameters from request, so we don't have problems with resetting filters/sorting.But for action column we should use slightly different solution because, creteUrl will be executed for each row/column, so we need params 'caching' (may be in GridView widget) from request for avoiding
$paramsFromRequest = $request instanceof \yii\web\Request ? $request->getQueryParams() : [];calculating in each row.