Answer the question
In order to leave comments, you need to log in
How to display query data in gridview?
I still can’t catch up with how to display data from the request, or do it in activeRecord, or do it in the searchModel. I have several gridviews on different actions, and one table of orders. I now need to display all the data for a certain status in one action in the gridview.
In its pure form, the request will be like this.
I tried to implement it in yii in the file frontend\models\ZakazSELECT * FROM `zakaz` WHERE `status` = 5
public function getDisain()
{
$disain = Zakaz::findAll([
'status' => Zakaz::STATUS_DISAIN,
]);
}
public function actionDisain()
{
$searchModel = new ZakazSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$disain = Zakaz::findOne('status');
$disain = getDisain()->status;
return $this->render('disain', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'disain' => $disain,
]);
}
Answer the question
In order to leave comments, you need to log in
Good afternoon.
One gridview, one controller, one model, all for orders. Sorting in girdview by status. No need to write a lot of code!
Displaying orders as a table in a view that is connected in an action, this action is called index!!!
In the controller it should be so, and only so!!!
public function actionIndex()
{
$searchModel = new ZakazSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question