-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Option to have an ExpandRowColumn row always remain open until it is manually closed #912
Comments
This feature is already available via You should be able to set the value for the expand row column cell using Closure method to For example: [
'class' => 'kartik\grid\ExpandRowColumn',
'width' => '50px',
'value' => function ($model, $key, $index, $column) {
if ($model->status === 'FEATURED') { // keep it expanded for specific rows
return GridView::ROW_EXPANDED;
}
return GridView::ROW_COLLAPSED;
},
'detail' => function ($model, $key, $index, $column) {
return Yii::$app->controller->renderPartial('_expand-row-details', ['model' => $model]);
},
'headerOptions' => ['class' => 'kartik-sheet-style']
], |
The problem is I need to have all rows collapsed by default, then the user will randomly open any rows and those rows should remain open. Your example won't work since it only works for a use case where a row is "featured". So the user goes to the page, randomly opens any row (lets say row 5 that is no different than the rest of the rows), then goes to page 2 via pjax, then back to page 1 via pjax. Row 5 should remain open. |
That was just an example. It is an application level design and programming you need to do for your use case. You need to store the expanded states for the user in a table/storage and use this to set the column value via Closure method. |
@kartik-v I had set This is my code: [
'class' => 'kartik\grid\ExpandRowColumn',
'width' => '50px',
'value' => function ($model, $key, $index, $column) {
if ($model->id == 46) {
return GridView::ROW_EXPANDED;
} else {
return GridView::ROW_COLLAPSED;
}
},
'detail' => function ($model, $key, $index, $column) {
return Yii::$app->controller->renderPartial('view', ['model' => $model]);
},
'headerOptions' => ['class' => 'kartik-sheet-style'],
'expandOneOnly' => true
],
` |
I got this issue too, since grid updated from 3.3.4 to 3.3.5, defaultHeader and value as ROW_EXPANDED not working anymore. |
I got this issue too. just loading and stop but row not expand |
I am facing the same issue, Any solution for this? |
Just encountered similar issue I think - value not working. Downgrading helped. |
Can confirm that this is a real issue, and it was corrected by downgrading to 3.3.4. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Prerequisites
master
branch of yii2-grid.We would like a row that is expanded to always remain open even after a page refresh or a pjax pagination change, etc.
An example of this on the demo page would be to have the Grapes of Wrath row remain expanded after clicking to go to page 2 and then clicking to go back to page 1.
Another example would be if the Grapes of Wrath row were expanded and and the Add to Cart button was pressed and then the user checked out and was redirected back to the demo page, that row would still be expanded.
Or an option to open a row via javascript would also help. I can keep track of which row was opened and then upon page refresh, call some function like
kv_ExpandRow('2')
and it will expand row 2 upon page load.The text was updated successfully, but these errors were encountered: