码迷,mamicode.com
首页 > 其他好文 > 详细

YII2 gridview

时间:2017-02-14 19:10:34      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:order   tip   page   border   cursor   data-   class   ext   content   

<?= \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

标签:order   tip   page   border   cursor   data-   class   ext   content   

原文地址:http://www.cnblogs.com/yangyuqiu/p/6398867.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!