标签:
有些时候,需要多表关联查询,使用SqlDataProvider比较灵活
Controller中
use yii\data\SqlDataProvider;
$dataProvider = new SqlDataProvider([ ‘sql‘ =>$sql, ‘totalCount‘ => $totalCount, ‘pagination‘ => [ ‘pageSize‘ => 10, ], ]);
$gridcolumn[0]=[‘class‘=>‘kartik\grid\SerialColumn‘]; $gridcolumn[1]=[‘label‘=>‘AA‘,‘value‘=>"name"]; //省略
View中
<?= GridView::widget([ ‘dataProvider‘ => $dataProvider, ‘columns‘ =>$gridcolumn,
]); ?>
标签:
原文地址:http://www.cnblogs.com/baby123/p/5103099.html