kartik-v / yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
http://demos.krajee.com/grid
Other
556 stars 303 forks source link

write string in action column ExpandRowColumn #955

Closed serie1bmw closed 4 years ago

serie1bmw commented 4 years ago

Prerequisites

Expected behavior and actual behavior

It's possible add code in action column to expand ExpandRowColumn like with anonymous function? I need add in this column total rows in each ExpandRowColumn like in image https://i.imgur.com/YDQ0nL9.jpg

example in expandIcon property:

[
    'class' => 'kartik\grid\ExpandRowColumn',
    'width' => '50px',
    'expandIcon' => function ($model, $key, $index, $column) {
    $total = Model::find()->where(['id_model' => $model->id])->count();
        return '<i class="fa fa-plus-square"></i> ' . $total;
    },
    'value' => function ($model, $key, $index, $column) {
        return GridView::ROW_COLLAPSED;
    },
    'detail' => function ($model, $key, $index, $column) {
        return Yii::$app->controller->renderPartial('_expand-row-details', ['model' => $model]);
    },
],
stale[bot] commented 4 years ago

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.

kartik-v commented 4 years ago

No - unfortunately - this will not be a trivial change - and will require a great change to the javascript.

I recommend a solution for you is to add another DataColumn just adjacent to the ExpandRowColumn to show the total or your additional information