$query = self::find().....
$query->andFilterWhere(['like', 'username', $this->username]);
$query = new Query();
$query->andWhere(['some' => $this->some]);
// ... тут всякие другие условия
$dataProvider = new SqlDataProvider([
'totalCount' => $query->count(),
'sql' => $query->createCommand()->sql,
]);
$dataProvider = new SqlDataProvider([
'sql' => 'SELECT * FROM user WHERE status=:status',
'params' => [':status' => 1], // <--------------
'totalCount' => $count,
'sort' => [
'attributes' => [
'age',
'name' => [
'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC],
'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC],
'default' => SORT_DESC,
'label' => 'Name',
],
],
],
'pagination' => [
'pageSize' => 20,
],
]);