Page size does not work after added sorting in the gridview data provider query.
Here is my code
$query = TenantDetails::find()
->select([
'id' => 'tenant_details.id',
'first_name' => 'tenant_details.first_name',
'last_name' => 'tenant_details.last_name',
'business' => 'tenant_details.business',
'fax' => 'tenant_details.fax',
'address' => 'tenant_details.address',
'city' => 'tenant_details.city',
'state' => 'tenant_details.state',
'zip' => 'tenant_details.zip',
'phone' => 'tenant_details.phone',
'phone_ext' => 'tenant_details.phone_ext',
'phone_label' => 'tenant_details.phone_label',
'email' => 'tenant_details.email',
'emergency_contact' => 'tenant_details.emergency_contact',
'emergency_phone' => 'tenant_details.emergency_phone',
'emergency_contact_ext' => 'tenant_details.emergency_contact_ext',
'partners_name' => 'tenant_details.partners_name',
'more_contact' => 'tenant_details.more_contact',
'status' => 'tenant_details.status',
'agreement_type' => 'tenant_details.agreement_style'
]);
$query->leftJoin('agreement', 'agreement.tenant_id = tenant_details.id');
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if(isset($params['TenantFormModel']['status'])){
$this->status = $params['TenantFormModel']['status'];
}
else{
$this->status = CommonHelpers::STATUS_ACTIVE;
}
//echo '<pre>'; \yii\helpers\VarDumper::dump($params['phone']); die();
if(!empty($params['phone'])){
$phone = $this->phoneNumberFormat($params['phone']);
$this->phone = $phone;
}
// adjust the query by adding the filters
$query->andFilterWhere(['like','tenant_details.first_name', $this->first_name]);
$query->andFilterWhere(['like','tenant_details.last_name', $this->last_name]);
$query->andFilterWhere(['like','tenant_details.email', $this->email]);
$query->andFilterWhere(['like','tenant_details.phone', $this->phone]);
$query->andFilterWhere(['=','tenant_details.status', $this->status]);
$query->andFilterWhere(['=','tenant_details.id', $this->id]);
$dataProvider->pagination =[
'pageSize'=>25
];
// adjust the query by adding sort orders
$dataProvider->sort = [
'defaultOrder' => [
'id'=>SORT_ASC,
],
];