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', ]); }, ] ], ], ]); ?>
相关文章推荐
- 浅析Yii2中GridView常见操作
- Yii2中关联数据表数据在gridview中的显示,查询(search)和排序(sort)等。
- yii2 GridView 日期格式化并实现日期可搜索 案例
- yii2-GridView在开发中常用的功能及技巧总结
- yii2中GridView使用进阶
- yii2使用gridView实现下拉列表筛选数据
- Yii2-GridView自定义数据列
- Yii2 GridView 中对columns的定义
- yii2 GridView常见操作
- yii2之GridView小部件
- YII2 GridView与AutoComplete
- YII2 GridView联表搜索,排序
- yii2自定义GridView和ActionColumn
- yii2 gridview 新增按钮 动态显示按钮
- [联表] -- YII2 GridView联表:文本框搜索、下拉框选择搜索和排序
- Yii2-GridView
- yii2 gridview
- yii2 GridView常见操作
- 浅析Yii2 GridView实现下拉搜索教程
- [ActiveDataProvider] -- yii2的GridView和ActiveDataProvider具体使用