Need a hint. I master Yii2 and there was a problem. There is a table USER and GridView with data from this table - filtering works. And there is a table SEND and GridView with data from this table - here it does not perform filtering. The code was taken from the User class and SearchUser.
CONTROLLER
public function actionAllsend(){ if(isAdmin()){ $searchModel = new SendSearch(); //ΠΠΎΠ»ΡΡΠΈΠΌ Π·Π°ΠΏΠΈΡΠΈ ΠΏΠΎ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΠΎΠΌΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('allsend', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); } else{ return $this->redirect(['site/index']); } } MODEL
public function search($params, $userName = null) { $this->load($params); // ΠΠΎΠ»ΡΡΠΈΠΌ Π²ΡΠ΅ Π·Π°ΠΏΠΈΡΠΈ Π»ΠΈΠ±ΠΎ Π·Π°ΠΏΠΈΡΠΈ ΠΏΠΎ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΠΎΠΌΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ if($userName == null){ $query = Send::find(); // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, ]); $query->andFilterWhere(['like', 'user_id', $this->user_id]) ->andFilterWhere(['like', 'type', $this->type]) ->andFilterWhere(['like', 'date', $this->date]) ->andFilterWhere(['like', 'status', $this->status]); } else{ $query = Send::find(); $query->andFilterWhere([ 'user_id' => $userName, ]); } // echo $query; $dataProvider = new ActiveDataProvider([ 'query' => $query, 'pagination' => [ 'forcePageParam' => false, 'pageSizeParam' => false, 'pageSize' => 20 ] ]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } return $dataProvider; } VYUHA
<div class="admin-all-send"> <h1><?= Html::encode($this->title) ?></h1> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ //['class' => 'yii\grid\SerialColumn'], ['attribute'=>'id', "label"=>'Π£Π½ΠΈΠΊΠ°Π»ΡΠ½ΡΠΉ Π½ΠΎΠΌΠ΅Ρ ΡΠ°ΡΡΡΠ»ΠΊΠΈ'], ['attribute'=>'date', "label"=>'ΠΠ°ΡΠ° ΡΡΠ°Π½Π·Π°ΠΊΡΠΈΠΈ'], ['attribute'=>'user_id', 'label'=>'Π§ΡΡ ΡΠ°ΡΡΡΠ»ΠΊΠ°'], ['attribute'=>'type', 'label'=>'Π’ΠΈΠΏ ΡΠ°ΡΡΡΠ»ΠΊΠΈ'], ['attribute'=>'status', "label" => "Π‘ΡΠ°ΡΡΡ ΡΠ°ΡΡΡΠ»ΠΊΠΈ"], ['attribute'=>'price', 'label'=>'Π¦Π΅Π½Π° ΡΠ°ΡΡΡΠ»ΠΊΠΈ'], ['class' => 'yii\grid\ActionColumn', 'template' => '{view} {delete}', ], ], ]); ?> </div>