Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

How To Make Custom Column Of Cgridview Filterable ?

$
0
0
Hi guys I have been searching for the solution to this problem from more than a week.
I saw many posts , but none of them seems to work for me.
Problem :

I have a column in CGridView which calls a function in my model and make some queries and return a value

Example:

View:

'columns'=>array(
		'UserGroupName',
                 array( 'name'=>'Attendence', 
                   'value'=>'$data->getAttendence()',
                   'header'=> 'Attendence',
                    
                   ),


Model:

 public function getAttendence(){
            //some math
            $userIDs = $this->getUserIDs();
            $totalDeliveredToThisGroup= $this->getDeliveredCount($userIDs);
            $totalSeen = $this->getSeenByCount($userIDs);
           
            if($totalDeliveredToThisGroup==0)
                  return '0%';
              else
                  return round(floatval(($totalSeen/$totalDeliveredToThisGroup)*100),2).'%';
        }




Note: I can get the values for corresponding rows in CGridView. How ever I am not able to (is there a way ?) sort or filter by this column.

Help !!!

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>