您的位置:首页 > 编程语言 > PHP开发

YII2 gridview

2017-02-14 18:21 155 查看
<?= \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="'
. Yii::$app->urlManager->createUrl('test/index')
. '?id="+(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',
]);
},
]
],
],
]); ?>


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: