这是我在yii中用Cgridview编写的代码。
array(
'header'=>'Avg Rating',
'type' => 'raw',
'value'=>'$this->grid->controller->widget(\'CStarRating\',
array(
\'name\'=>$data->rating.$data->id,
\'id\'=>$data->id,
\'readOnly\' => true,
\'value\' =>2.5,
\'minRating\'=>1,
\'maxRating\'=>5,
\'htmlOptions\'=>array(\'style\'=>\'text-align:center;\',)),true)." <br/>1,011 Reviews"',
'htmlOptions'=>array('style'=>'text-align:center;'),
),
当我传递整数时,它会显示正确的填充星形,但是当我传递2.5之类的值时,它会显示所有星形空白。
答案 0 :(得分:0)
你必须这样做:
array(
'header'=>'Avg Rating',
'type' => 'raw',
'value'=>'$this->grid->controller->widget(\'CStarRating\',
array(
\'name\'=>$data->rating.$data->id,
\'id\'=>$data->id,
\'readOnly\' => true,
\'value\' =>2.5,
\'minRating\'=>0.5,
\'maxRating\'=>5,
\'ratingStepSize\' => 0.5,
\'htmlOptions\'=>array(\'style\'=>\'text-align:center;\',)),true)." <br/>1,011 Reviews"',
'htmlOptions'=>array('style'=>'text-align:center;'),
),
或可以尝试minRating
和ratingStepSize
的其他值。