实施kartik dynagrid
但是只能传递变量的错误。
这是我尝试过的代码:
列
<?php
$columns = [
'id',
'username',
'first_name',
'other_names',
'email',
[
'class' => ActionColumn::className(),
'header' => 'Roles',
'template' => '{assign-roles}',
'buttons' => [
'assign-roles' => function ($url, $model, $key) {
return Html::a("Assign Role", $url);
}
]
],
[
'class' => ActionColumn::className(),
'header' => 'Action',
'buttons'=>[
'delete'=>function($url, $model, $key){
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
'title' => Yii::t('yii', 'Delete'),
'data-confirm' => Yii::t('yii', 'Are you sure to delete this item ?'.
'We recommend deactivating the user to avoid inconcistencies with the data this user handled'),
'data-method' => 'post',
]);
}
]
]
];
这是grid
echo DynaGrid::widget([
'columns' => $columns,
'showPersonalize' => true,
'options' => ['id' => 'dynagrid-users'],
'gridOptions' => [
'dataProvider' => $dataProvider,
'pager' => [
'firstPageLabel' => 'First',
'lastPageLabel' => 'Last',
'maxButtonCount' => 10,
],
'panel' => [
'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i> All Users</h3>',
'before' =>
'<i>* All Users in the database</i><br>',
//'after'=>Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset Grid', ['index'], ['class' => 'btn btn-info']),
'footer' => true
],
'toolbar' => [
['content' => '{dynagridFilter}{dynagridSort}{dynagrid}'],
'{export}',
'{toggleData}'
],
'pjax' => true,
'bordered' => true,
'striped' => true,
'condensed' => true,
'responsive' => true,
'responsiveWrap' => false,
]
]);
?>
我总是收到一个错误,只有变量应该通过引用传递。