我在我的控制器中创建了 sqlDataProvider 及其工作。我的问题是我不知道如何提供搜索字段,因为我没有使用搜索模型。
这是我的控制器中的代码
public function actionAnalisa()
{
$sql = "SELECT
tbl_permohonan.permohonan_id As permohonan_id,
user.id As id,
tbl_moderator.bm_id As bm_id,
tbl_bhgnmod.unit_kampuscawangan As unit_kampuscawangan,
tbl_bahagian.bahagian_nama As bahagian_nama,
tbl_unit.unit_nama As unit_nama
FROM tbl_permohonan
INNER JOIN user
ON tbl_permohonan.user_id=user.id
INNER JOIN tbl_moderator
ON user.id=tbl_moderator.user_id
INNER JOIN tbl_bhgnmod
ON tbl_moderator.bm_id=tbl_bhgnmod.bm_id
INNER JOIN tbl_bahagian
ON tbl_bhgnmod.bahagian_id=tbl_bahagian.bahagian_id
INNER JOIN tbl_unit
ON tbl_bhgnmod.unit_id=tbl_unit.unit_id";
$dataProvider = new SqlDataProvider([
'sql' => $sql,
]);
return $this->render('analisis', [
// 'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
这是我的看法
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'permohonan_id',
'id',
'bm_id',
'unit_kampuscawangan',
'bahagian_nama',
'unit_nama',
//~ ['class' => 'yii\grid\ActionColumn'],
],
]); ?>