So, I finally have a progress bar in my GridView, thanks to the BootProgressColumn. However, I have a rating system, and I'd like to show the percentage inside the progress bar. I can set it the hard way in the columns
array, but that'll be for all the rows.
$rawData = Item::model()->findAllByAttributes(array('special_id' => $specialId));
$dataProvider = new CArrayDataProvider($rawData, array());
The GridView:
'dataProvider' => $dataProvider,
'columns' => array(
array(
'class' => 'application.components.BootProgressColumn',
'name' => 'Rating',
'animated' => true,
'striped' => true,
'percent' => '44',
),
)
Now, how do I get the sum of all columns where each respective $data->id
matches rows in the Rating
model?
$countRatings = count(Rating::model()->findAllByAttributes(array('item_id' => $data->id));
But what to do for sum? And how to divide sum by count? That all having done, how to get it in each column? Or would it be best to just create a table by myself?