在 kartik dynagrid 中添加自定义操作时出错
Error in adding a custom action in kartik dynagrid
我有一个发电机并在发电机中添加了一个额外的列,但它不起作用。
我试过:
<?php
$columns = [
['class' => 'yii\grid\SerialColumn',],
'officename',
[
'class' => ActionColumn::className(),
'header' => 'Units',
'template' => '{add-units}',
'buttons' => [
'assign-roles' => function ($url, $model, $key) {
return Html::a("Add Units", $url);
}
]
],
];
echo DynaGrid::widget([
'columns' => $columns,
'showPersonalize' => true,
'options' => ['id' => 'dynagrid-users'],
'gridOptions' => [
'dataProvider' => $dataProvider,
'pager' => [
'firstPageLabel' => 'First',
'lastPageLabel' => 'Last',
'maxButtonCount' => 10,
],
'pjax' => true,
'bordered' => true,
]
])
?>
添加单位不显示单词 (Add Units) 可能是错误的
您自定义了操作栏模板并提供了一个新栏 add-units
但您在按钮选项 assign-roles
下提供了不同的名称。两者应该相同
[
'class' => ActionColumn::className(),
'header' => 'Units',
'template' => '{add-units}',
'buttons' => [
'add-units' => function ($url, $model, $key) {
return Html::a("Add Units", $url);
}
]
],
我有一个发电机并在发电机中添加了一个额外的列,但它不起作用。 我试过:
<?php
$columns = [
['class' => 'yii\grid\SerialColumn',],
'officename',
[
'class' => ActionColumn::className(),
'header' => 'Units',
'template' => '{add-units}',
'buttons' => [
'assign-roles' => function ($url, $model, $key) {
return Html::a("Add Units", $url);
}
]
],
];
echo DynaGrid::widget([
'columns' => $columns,
'showPersonalize' => true,
'options' => ['id' => 'dynagrid-users'],
'gridOptions' => [
'dataProvider' => $dataProvider,
'pager' => [
'firstPageLabel' => 'First',
'lastPageLabel' => 'Last',
'maxButtonCount' => 10,
],
'pjax' => true,
'bordered' => true,
]
])
?>
添加单位不显示单词 (Add Units) 可能是错误的
您自定义了操作栏模板并提供了一个新栏 add-units
但您在按钮选项 assign-roles
下提供了不同的名称。两者应该相同
[
'class' => ActionColumn::className(),
'header' => 'Units',
'template' => '{add-units}',
'buttons' => [
'add-units' => function ($url, $model, $key) {
return Html::a("Add Units", $url);
}
]
],