H
H
hollanditkzn2017-03-24 15:47:36
Yii
hollanditkzn, 2017-03-24 15:47:36

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,
            ]);
    }

In frontend\controllers\ZakazController controller
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,
        ]);
    }

How to build the code correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-03-24
@hollanditkzn

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,
        ]);
    }

That's it, nothing else needs to be fenced. For the status drop down list.
Crap!!!
Yes, how much can you?!
Read the articles on the links, everything is painted there to the smallest detail !!!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question