Skip to content

Yii2 ActiveDataProvider fetch result correct but showing totalCount 0 in summary text #12141

@ak868308

Description

@ak868308

I am trying to filter data using dropdown so the query executed perfectly produces a result is always correct but in summary total count is '0' always but not first time when page loaded. This is annoying me I am completely unable to trace the error through debugging tool. But the important thing is that the same code is working fine on my local machine whenever I deployed the same code to production it shows 0 counts
My Model search code :

`public function search($params) {

$query = Tasks::find();

$query->where(['q_id' => $this->job_id]);

// $query->orderBy('created_at DESC');

$dataProvider = new ActiveDataProvider([
    'query' => $query,
    'pagination' => [
        'pageSize' => 20,
    ],
]);


$this->load($params);

if (!empty($this->keyword) || $this->keyword != '') {

    $query->andWhere('MATCH(task_title,task_description, priority) AGAINST("' . $this->keyword . '*" IN BOOLEAN MODE)');
}

if (is_numeric($this->filterby)) {
    $query->andFilterWhere(['status' => $this->filterby]);
} else {
    $query->andFilterWhere(['IN', 'status', [10, 4, 2]]);
}

if (!empty($this->sortby) || $this->sortby != '') {
    $query->orderBy($this->sortby . ' DESC');
}

return $dataProvider;

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions