Yii Framework Forum: CGridView rowCssClassExpression - Yii Framework Forum

Jump to content

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

CGridView rowCssClassExpression Rate Topic: -----

#1 User is offline   wyldie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-May 09

Posted 25 February 2010 - 09:39 AM

Any idea how I can use CGridView rowCssClassExpression? I realise it's a PHP expression, however when I try something like this, I get the TR class set to "row-closed" no matter what the value of "open_ticket".

$this->widget('zii.widgets.grid.CGridView', array(
	'dataProvider'=>$dataProvider,
	'showTableOnEmpty'=>true,
	'emptyText'=>'This ticket folder is empty. ',
	'rowCssClassExpression'=>'$data->open_ticked?"row-open":"row-closed"',
	'columns'=>array(
		array(
			'class'=>'CCheckBoxColumn',
			'name'=>'delete',
			'value'=>'$data->id',
			'id'=>'delete'
		),
		array(
			'name'=>'subject.value',
			'header'=>'Subject',
			'value'=>'CHtml::link($data->subject->value, array("ticket/read", "id"=>$data->id)',
			'type'=>'raw'
		),
		array(
			'class'=>'CButtonColumn'
		),
	),
));

0

#2 User is offline   wyldie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-May 09

Posted 25 February 2010 - 11:31 PM

anyone? - bump
0

#3 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,897
  • Joined: 04-October 08
  • Location:DC, USA

Posted 26 February 2010 - 12:00 AM

You cannot use $data variable. You need to use $this->dataProvider->data[$row] to refer to the model associated with the row.
0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,897
  • Joined: 04-October 08
  • Location:DC, USA

Posted 26 February 2010 - 12:04 AM

I just added support so that you can use $data directly in the expression.
0

#5 User is offline   wyldie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-May 09

Posted 26 February 2010 - 12:25 AM

thanks qiang - you star!
0

#6 User is offline   Touzas 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-November 11

Posted 22 March 2013 - 03:58 AM

I probed this solution and not rules. Only rules:

'rowCssClassExpression'=>'$data["open_ticked"]?"row-open":"row-closed"',

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