I
I
Igor Braduloff2018-08-29 17:25:16
Yii
Igor Braduloff, 2018-08-29 17:25:16

How to search by field in GridView?

Good afternoon! Using a stored procedure, I get the data as an array and then format it as a Grid Can you tell me how to search for each field in a GridView?
Controller

$dataProvider = new ArrayDataProvider([
            'allModels' => $records,
            'sort' => [
                'attributes' => ['State Time'],
            ],
            'pagination' => [
                'pageSize' => 15,
            ],
        ]);
        return $this->render('index',compact('dataProvider'));

view
echo GridView::widget([
             'dataProvider'=>$dataProvider,
             'filterModel'=>$searchModel,
             'columns'=>[
                     ['class' => 'yii\grid\SerialColumn'],
                     'RecipientLegalName',
                     'Service Name',
                     'Payment Identifier',
                     'Payment Number',
                     'Payment Account',
                     'Recipient Sum, MDL',
                     'Payment State',
                     'State Time',
             ],
     ]);

How to correctly describe $searchModel so that each field is searched. How the model should be described. I don't use model generator.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-09-03
@webinar

I don't use model generator.

In vain, it will generate exactly what you need. If religion does not allow the use of gii, then what do you suggest, to write a search model for you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question