1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<?= GridView::widget([ 'dataProvider' => $dataProvider , 'filterModel' => $searchModel , //列头搜索框 'columns' => [ [ 'class' => 'yii\grid\SerialColumn' ], //列头序号 [ 'class' => 'yii\grid\CheckboxColumn' ], //列头checkbox 'id' , 'arc_title' , 'arc_author' , 'arc_createtime' , 'arc_updatetime' , 'arc_content:ntext' , // 'arc_review', //显示图片 'label_img' =>[ 'label' => '标签图' , 'format' => 'raw' , 'value' => function ( $model ){ return Html::img( "assets/111.jpg" ,[ 'class' => 'img-circle' ]); //圆形图片 } ], //显示状态 [ 'attribute' => 'is_valid' , 'label' => '发布状态' , 'value' => function ( $model ) { return $model ->arc_review == 0 ? '未发布' : '已发布' ; }, 'filter' => [ 0 => '未发布' , 1 => '发布' ] ], //['class' => 'yii\grid\ActionColumn'],//增删改查 //改进增删改查 [ 'class' => 'yii\grid\ActionColumn' , 'template' => '{test} {aaa} {update}' , 'header' => '操作' , 'buttons' => [ //此处的test与'template'中'test'想同 'test' => function ( $url , $model , $key ) { return Html::a( '测试按钮' , $url ,[ 'data-method' => 'post' , 'data-pjax' => '0' ]); }, 'aaa' => function ( $url , $model , $key ) { return Html::a( '测试按钮' , $url ,[ 'data-method' => 'post' , 'data-pjax' => '0' ]); }, ], ], ], ]); ?>
|