controller
public function actionIndex(){ $myUser = new MyUser(); $myuserQuery = $myUser::find()->select(['fuid','fusername','femail','fstatus','fname'])->join(' LEFT JOIN','wanguan_roles','wanguan_admin.frule = wanguan_roles.fid'); $listDataProvider = new ActiveDataProvider([ 'query' => $myuserQuery, 'pagination' => [ 'pageSize' => 50, ], ]); return $this->render('list', ['listDataProvider' => $listDataProvider]); }
view
<?php echo GridView::widget([ 'summary'=>false, 'dataProvider' => $listDataProvider, 'pager'=>[ 'firstPageLabel'=>'首页', 'lastPageLabel'=>'尾页', 'nextPageLabel'=>'下一页', 'prevPageLabel'=>'上一页', 'maxButtonCount'=>6, ], 'columns'=>[ [ 'attribute'=>'fusername', 'label'=>'用户名', ], [ 'attribute'=>'femail', 'label'=>'邮箱' ], [ 'attribute'=>'fstatus', 'label'=>'状态', 'format'=>'raw', 'value'=>function($model){ return $model['fstatus']==1?Html::tag('span','有效',['class'=>'label label-success','id'=>$model['fuid'],'data'=>['id'=>$model['fuid']]]):Html::tag('span','无效',['class'=>'label label-default','id'=>$model['fuid'],'data'=>['id'=>$model['fuid']]]); } ], [ 'attribute'=>'fname', 'label'=>'角色', 'value'=>function($model){ return isset($model->fname)?$model->fname:''; } ] ] ]);?>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。