Asaf Maoz
Asaf Maoz

Reputation: 675

CSqlDataProvider yii sorting after manipulating data

I am showing data from CSqlDataProvider with pagination, I want to add sorting for my results
my situation is-
I get the data with

    $dataProvider=new CSqlDataProvider($sqlAll, array(
                'totalItemCount'=>$count,
                'pagination'=>array('pageSize'=>$pageSize,),
                'params' => $params
            ));
    
after I get the results I calculate 2 more fields to show(which are not extracted with the $sqlAll query) and sort according to them
My problem is: I only get the $pagesize amount of results, and what happens is that the sorting is per $pagesize results and not from all the results.
can I add the calculated fields to the CSqlDataProvider or pagination?

Upvotes: 1

Views: 148

Answers (1)

Tommy Bravo
Tommy Bravo

Reputation: 532

You could add the calculated fields in one of two ways:

  1. Calculate the results of the two fields directly in the query and sort on that.
  2. Use a CArrayDataProvider and fill it with the data from the associative array of the query result (get this result using the DAO) to which you added the two fields "manually".

Upvotes: 1

Related Questions