Yii Framework Forum: star rating and ajax enabled gridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

star rating and ajax enabled gridview Rate Topic: -----

#1 User is offline   shayan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 10-October 11

Posted 05 April 2012 - 04:37 AM

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?
0

#2 User is offline   VINAY Kr. SHARMA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 13-September 11
  • Location:Gurgaon

Posted 05 April 2012 - 04:51 AM

View Postshayan, on 05 April 2012 - 04:37 AM, said:

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',
            'type'=>"html", 
        ),
...
// in contrller
protected function getStar_Rating
{
..
$this->renderPartial('rating',..);
...
}

// rating.php in view
 $this->widget('CStarRating',array(..))

VINAY Kr. SHARMA
@vinaykrsharma
Facebook ID: vinaykrsharma
Blog

Co-operation comes from friendship, friendship comes from trust, and trust comes from kind-heartedness.
0

#3 User is offline   shayan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 10-October 11

Posted 05 April 2012 - 05:17 AM

thank u.
i tested it. but it didn't work. i think problem is with renderPartial (grid view ajaxupdate) not column type
0

#4 User is offline   talby101 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 26-August 10
  • Location:Wales

Posted 06 April 2012 - 12:52 AM

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(), 
		       
		),
    ),
    
));   



0

#5 User is offline   Rohit Suthar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 220
  • Joined: 12-May 14
  • Location:Mumbai, India

Posted 04 July 2014 - 07:23 AM

for best help follow this wiki -

Managing a star rating with the StarRating widget in Yii 2

and use Star Rating Yii Widget..
Thanks & regards,

ROHIT SUTHAR
Mumbai(India)

Follow me - @rohisuthar

www.yiiframework.us
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users