美文网首页
ActiveDataProvider与GridView::wid

ActiveDataProvider与GridView::wid

作者: IT_min | 来源:发表于2017-06-01 18:03 被阅读0次

    //ActiveDataProvider与GridView::widge的使用

    public function actionTopic()
        {
            $dataProvider = new ActiveDataProvider([
                'query' => Topic::find()
                        ->where('end_time >=' . $_SERVER['REQUEST_TIME'])
                        ->andWhere('start_time <=' . $_SERVER['REQUEST_TIME'])
                        ->orderBy(['topic_id' => SORT_DESC]),
            ]);
            return $this->render('topic', [
                        'dataProvider' => $dataProvider,
            ]);
        }
    view/goods/topic.php
    GridView::widget([
        'dataProvider' => $dataProvider,
        'filterPosition' => false, //关闭Yii默认搜索栏
        'layout' => "{items}{summary}{pager}",
        'summary' => '共{totalCount}个记录,每页{count},共{pageCount}页',
        'columns' => [
            'topic_id',
            'title',
            'start_time:datetime',
            [
                'attribute' => '二维码',
                'format' => 'raw',
                'value' => function ($data)
                {
                    return Html::a('二维码', '#', [
                                'data-toggle' => 'modal',
                                'data-target' => '#myModal',
                                'class' => 'btn btn-primary topic_ids',
                                'id' => $data->topic_id,
                    ]);
                },
                    ],
                ],
            ])

    相关文章

      网友评论

          本文标题:ActiveDataProvider与GridView::wid

          本文链接:https://www.haomeiwen.com/subject/kgbefxtx.html