Problem With Sorting


i have 2 models User and Calls with User has many Calls i need to show data in cGridview,data is showing correctly but i need to apply cGridview i had an attribute ‘Called?’ Which have value ‘yes’ or ‘no’ which represent if Calls Model Have a record corresponding to User.i am using a function in controller to show ‘yes’ or ‘no’ in cGridview based on Calls model have an entry or not. How can i implemet sorting on this field?thanks in advance

Pass the return value of that function to the dataProvider used for the GridView. For more, refer to this link:

thanks BCR for help

but can you tell me how can i "Pass the return value of that function to the dataProvider used for the GridView" as suggested by you

my guess from ex. is that it need to be define with following statement


can you explain a bit more?thanks

I’ll need to have a look at your view & controller for that.

this is the view





            'value'=>array($this, 'ccaleadstatus'),


                    'class'=> 'adminleadId',


            ) ,

this is in controller

public function ccaleadstatus($data) {

    $return = isset($data->wish_ccacall["id"])?"Yes":"No";

    return $return;




Please can anybody tell me if i use a function to show value of a colomn in gridview and this function show value from database but if the value is not available in database then it show ‘no’ custom text.can anybody tell be how can i sort this colomn.thanks in advance.can somebody show this by example?thanks in advance

Hi prashant.tyagi,

This is a kind of STAT relation. It’s relatively easy to display it in the grid.

But in order to filter/sort by this kind of calculated data, you need to do some trick. In short, we can make use of sub query in SELECT clause and in WHERE clause when we define the criteria.

Please take a look at this wiki article: