Yii GridView::widget

Posted cxscode

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Yii GridView::widget相关的知识,希望对你有一定的参考价值。

GridView::widget文档
http://demos.krajee.com/grid

GridView::widget([
        ‘dataProvider‘ => $dataProvider,
        ‘filterModel‘ => $searchModel,
        ‘options‘ => [‘id‘ => ‘grid‘],
        ‘filterPosition‘ => GridView::FILTER_POS_FOOTER,
        ‘layout‘ => ‘{items}{summary}{pager}‘,
        ‘hover‘ => true,
        ‘export‘ => false,
        ‘toggleData‘ => false,
        ‘filterSelector‘ => "select[name=‘" . $dataProvider->getPagination()->pageSizeParam . "‘],input[name=‘" . $dataProvider->getPagination()->pageParam . "‘]",
        ‘pager‘ => $pager,
        ‘rowOptions‘ => function ($model, $key, $index, $grid) use ($searchModel) {
            if ($model->appointment_paid_time) {
                return [‘style‘ => ‘color: red‘];
            } else {
                return [];
            }
        },
        ‘columns‘ => [
            [
                ‘class‘ => ‘kartikgridCheckboxColumn‘,
                ‘visible‘ => $userRole == Collection::ROLE_COLLECTION ? false : true,
                ‘checkboxOptions‘ => function ($model, $key, $index, $column) use ($userRole) {
                    if (!($model->status == Collection::STATUS_PENDING || $model->status == Collection::STATUS_FOLLOWING)) {
                        return [‘class‘ => ‘hide‘]; 
                    }
                },
            ],
            [‘class‘ => ‘kartikgridSerialColumn‘],
            [
                /*‘contentOptions‘ => function ($data) {
                    if($data->appointment_paid_time){
                        return [‘style‘ => ‘color: red‘];
                    }
                },*/
                ‘header‘ => ‘编号‘,
                ‘value‘ => function ($data) {
                    return $data->collection_id;
                }
            ],
        ],
]);

  



以上是关于Yii GridView::widget的主要内容,如果未能解决你的问题,请参考以下文章

yii2 后台怎么直接用/admin

Yii系列Yii2.0基础框架

我在哪里可以找到我的 yii 应用程序的 yii 版本?

Yii2 yii2mod/yii2-rbac

Yii2 错误 - 找不到类 'yii\mongodb\ActiveRecord'

没有 yii 的 Yii Activerecord