首页 > 代码库 > YII2 gridview
YII2 gridview
<?= \yii\grid\GridView::widget([ ‘id‘ => ‘table‘, ‘dataProvider‘ => $dataProvider, ‘layout‘=>"{sorter}\n{pager}\n{summary}\n{items}", ‘summary‘ => "Showing {begin} - {end} of {totalCount} items", ‘tableOptions‘ => [‘class‘ => ‘table table-bordered table-hover‘], ‘rowOptions‘ => function ($model, $key, $index, $grid) { return [ ‘style‘ => "cursor: pointer", ‘onclick‘ => ‘location.href="http://www.mamicode.com/‘"+(this.id);‘, ]; }, ‘columns‘ => [ [ ‘class‘ => ‘yii\grid\SerialColumn‘, ‘contentOptions‘ => [‘style‘ => ‘width: 20px;‘, ‘class‘ => ‘text-center‘], ], [ ‘class‘ => ‘yii\grid\DataColumn‘, ‘attribute‘ => ‘date‘, ‘headerOptions‘ => [‘class‘ => ‘text-center‘], ‘label‘ => ‘Date‘, ‘contentOptions‘ => [‘style‘ => ‘width: 130px;‘, ‘class‘ => ‘text-center‘], ], ‘template‘ => ‘{view}‘, ‘buttons‘ => [ ‘view‘ => function ($url, $model) { return \yii\helpers\Html::a(‘<div class="text-center"><em data-toggle="tooltip" data-placement="top" title="more detail" class="fa fa-external-link-square text-warning"></em></div>‘, (new yii\grid\ActionColumn())->createUrl(‘test/index‘, $model, $model[‘id‘], 1), [ ‘title‘ => Yii::t(‘yii‘, ‘view‘), ‘data-method‘ => ‘post‘, ‘data-pjax‘ => ‘0‘, ]); }, ] ], ], ]); ?>
YII2 gridview
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。