shayan
(Shayan3001)
April 5, 2012, 9:37am
1
i have a grid view. this grid view has a star rating column.
$this->widget('zii.widgets.grid.CGridView', array(
...
'columns'=>array(
'name'=>'star rating',
'value'=>array($this,'rating'),
),
...
// in contrller
protected function rating
{
..
$this->renderPartial('rating',
..
}
// rating.php in view
$this->widget('CStarRating',array(
..
when ajaxupdate in grid view is enabled and i change page, stars dont load but if i disable gridview ajaxupdate i have no problem.
it seems scripts for creating star doesn’t load when ajax update is enable.
what can i do?
$this->widget('zii.widgets.grid.CGridView', array(
...
'columns'=>array(
'name'=>'star_rating',
'type'=>"html",
),
...
// in contrller
protected function getStar_Rating
{
..
$this->renderPartial('rating',..);
...
}
// rating.php in view
$this->widget('CStarRating',array(..))
shayan
(Shayan3001)
April 5, 2012, 10:17am
3
thank u.
i tested it. but it didn’t work. i think problem is with renderPartial (grid view ajaxupdate) not column type
spidee
(Spiro)
April 6, 2012, 5:52am
4
Try embedding the CStarRating widget in your gridview and init of the plugin within afterAjaxUpdate (the inputs need a class name that you can use a jQuery selector).
$this->widget('zii.widgets.grid.CGridView', array(
'afterAjaxUpdate'=>'function(id,data){ $(\'.star-rating > input\').rating(); }',
'dataProvider'=>$dataProvider
'columns'=>array(
array(
'name'=>'rating',
'type'=>'raw',
'value'=>'$this->grid->controller->widget("CStarRating",
array("starCount"=>"5",
"minRating"=>"1",
"maxRating"=>"5",
"allowEmpty"=>true,
"name"=>$data->id,
"id"=>"rating_" . $data->id,
),true)',
'htmlOptions'=>array(),
),
),
));
for best help follow this wiki -
Managing a star rating with the StarRating widget in Yii 2
and use Star Rating Yii Widget…