Yii Framework Forum: CGridView problem - Yii Framework Forum

Jump to content

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

CGridView problem Rate Topic: -----

#1 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 12 February 2010 - 05:02 AM

I am using the CGridView to view the cats table and I have an array $acts(1=>'active',0=>'unactive').
So I set this but it does not work, what is wrong? (cat_active has values 1,0 )

$this->widget('zii.widgets.grid.CGridView', array(
	'dataProvider'=>$dataProvider,
	'columns'=>array(		
		'cat_tittle',
		array('name'=>'cat_active','value'=>$acts[$data->cat_active]),
		
		array(
			'class'=>'application.components.ButtonColumn',
		),
	),
));

Posted Image
0

#2 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 747
  • Joined: 02-February 09

Posted 12 February 2010 - 05:38 AM

View Postdimis283, on 12 February 2010 - 05:02 AM, said:

I am using the CGridView to view the cats table and I have an array $acts(1=>'active',0=>'unactive').
So I set this but it does not work, what is wrong? (cat_active has values 1,0 )

$this->widget('zii.widgets.grid.CGridView', array(
	'dataProvider'=>$dataProvider,
	'columns'=>array(		
		'cat_tittle',
		array('name'=>'cat_active','value'=>$acts[$data->cat_active]),
		
		array(
			'class'=>'application.components.ButtonColumn',
		),
	),
));




try this:

array('name'=>'cat_active','value'=>'$acts[$data->cat_active]'),


[not tested]
0

#3 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 12 February 2010 - 05:44 AM

Now nothing is shown at this attr , I thing because I use an array.
When I set $acts[1] I see the 'active' , something is wrong with $data->cat_active
Posted Image
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,336
  • Joined: 12-October 09
  • Location:Croatia

Posted 12 February 2010 - 06:08 AM

View Postdimis283, on 12 February 2010 - 05:44 AM, said:

Now nothing is shown at this attr , I thing because I use an array.
When I set $acts[1] I see the 'active' , something is wrong with $data->cat_active


I solved similar problem with a function...
before calling CGridView make a function like:
function getStatus($id)
{
   $acts(1=>'active',0=>'unactive');
   return $acts[$id];
}

then in the call to CGridView use:
...
'cat_tittle',
array('name'=>'cat_active','value'=>'getStatus($data->cat_active)'),
...

Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 12 February 2010 - 06:16 AM

Very strange but it works.
Posted Image
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