Пример #1
0
 /**
  * Lists all Topic models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new TopicSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $gridColumns[] = ['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '36px', 'header' => '序号', 'headerOptions' => ['class' => 'kartik-sheet-style']];
     $gridColumns[] = ['attribute' => 'user_id', 'vAlign' => 'middle', 'width' => '180px', 'value' => function ($searchModel, $key, $index, $widget) {
         return $searchModel->user->username;
     }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(User::find()->orderBy('username')->asArray()->all(), 'id', 'username'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '用户'], 'format' => 'raw'];
     $gridColumns[] = ['attribute' => 'node_id', 'vAlign' => 'middle', 'width' => '180px', 'value' => function ($searchModel, $key, $index, $widget) {
         return $searchModel->node->name;
     }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Node::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '节点'], 'format' => 'raw'];
     $gridColumns[] = ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'need_login', 'vAlign' => 'middle', 'trueLabel' => '是', 'falseLabel' => '否'];
     $gridColumns[] = 'title';
     $gridColumns[] = 'click';
     $gridColumns[] = 'follow';
     $gridColumns[] = 'reply';
     $gridColumns[] = ['mergeHeader' => true, 'attribute' => 'created', 'format' => 'datetime'];
     $gridColumns[] = ['class' => '\\kartik\\grid\\ActionColumn', 'template' => '{view} {update} {delete}', 'buttons' => ['view' => function ($url, $model) {
         return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', Yii::$app->params['domain'] . $url, ['title' => '查看', 'target' => '_blank']);
     }]];
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'gridColumns' => $gridColumns]);
 }
Пример #2
0
 /**
  * Lists all Topic models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new TopicSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }