答案 0 :(得分:2)
如果您使用的是CRUD Generator,则可以修改index
视图,如下所示
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
// ...
[
'class' => 'yii\grid\ActionColumn',
'visibleButtons' => [
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE
]
],
],
]); ?>
还有另外一种方式,
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
// ...
[
'class' => 'yii\grid\ActionColumn',
// Only display `delete` button.
'template' => '{delete}',
],
],
]); ?>
答案 1 :(得分:1)
你可以隐藏这三个如下 1.转到您的views文件夹 2.找到你的文件夹名称(与表名相同) 3.现在打开文件夹并找到index.php 并且代码看起来像下面的代码,并使用//来隐藏列。只需在[&#39; class&#39;之前添加// =&GT; &#39; yii \ grid \ ActionColumn&#39;]正如我在代码中所示。
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'username',
'Address',
'Head',
'mobile',
'school',
'manager',
// ['class' => 'yii\grid\ActionColumn'],
],
]); ?>