'btn btn-primary']); $query = Notice::find()->where(['del' => EnumUtil::DELETE_NOT]); $provider = new ActiveDataProvider([ 'query' => $query, 'sort' => [ 'defaultOrder' => [ 'updated_at' => SORT_DESC, ] ], ]); echo GridView::widget([ 'dataProvider' => $provider, 'columns' => [ 'id', [ 'label' => '标题', 'headerOptions' => ['width' => '200'], 'value' => 'title', ], [ 'label' => '内容', 'headerOptions' => ['width' => '1200'], 'value' => 'message', ], 'updated_at_str', [ 'class' => 'yii\grid\ActionColumn', 'header' => '操作', 'template' => '{edit} {del}', 'buttons' => [ 'edit' => function ($url, $models, $key) { $url = ['/comm/notice-edit', 'id' => $models->id]; $options = ['title' => '修改',]; return Html::a('', $url, $options); }, 'del' => function ($url, $models, $key) { $url = ['/comm/notice-del', 'id' => $models->id]; $url = Url::to($url); $click='delConfirm("你确定要删除吗?","'.$url.'");'; $options = ['title' => '删除','class'=>'btn-link glyphicon glyphicon-remove', 'onclick' => $click]; return Html::button("", $options); } ] ], ], ]); ?>