是否可以在操作列中添加代码以像使用匿名函数一样扩展 ExpandRowColumn?我需要在每个 ExpandRowColumn 中添加此列的总行数,如下图所示。
属性示例expandIcon
:
[
'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]);
},
],