Yii Framework Forum: CGridView questions - Yii Framework Forum

Jump to content

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

CGridView questions Rate Topic: -----

#1 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,039
  • Joined: 30-October 09
  • Location:UK

Posted 02 March 2010 - 06:27 AM

I have the following questions regarding the CGridView:

1) I wish to combine 'Category' and 'Subcategory' models in my view. I have created the two separate CGridViews, however the CButtonColumn references the 'Category' controller actions by default - how can I make it reference the Subcategory controller actions?

2) How can I add a heading to the column above the CButtonColumn, for example 'Actions'.

3) How can I customize the headings of the existing columns?

Thanks.
0

#2 User is offline   qiang 

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

Posted 02 March 2010 - 07:24 AM

1. http://www.yiiframew...uttonUrl-detail
By default, it means the 'update' action of the current controller.
2. http://www.yiiframew...n#header-detail
3. Same as 2.
0

#3 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,039
  • Joined: 30-October 09
  • Location:UK

Posted 02 March 2010 - 07:39 AM

Cheers qiang. I did this:

'updateButtonUrl'=>"array('subcategory/update')",

So how can I now append the id= parameter to each of these URLs?
0

#4 User is offline   qiang 

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

Posted 02 March 2010 - 07:50 AM

Did you read the property API? It is a PHP expression and you can use $data to refer to the row of data. So you can write something like:
'Yii::app()->controller->createUrl("subcategory/update",array("id"=>$data->id))';
1

#5 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,039
  • Joined: 30-October 09
  • Location:UK

Posted 02 March 2010 - 10:48 AM

I got one last question for someone to answer. In my table I got a field that stores a multi-value data as such:

Value 1|Value 2|Value 3

I need to display this data in my CGridView, but delimited by a comma.

I tried this:

'value'=>'implode(", ", $data->parent_cats)',

But it just gives a blank cell. Anyone able to advise?
0

#6 User is offline   Maurizio Domba Cerin 

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

Posted 03 March 2010 - 06:42 AM

View PostGSTAR, on 02 March 2010 - 10:48 AM, said:

...
Value 1|Value 2|Value 3
...
'value'=>'implode(", ", $data->parent_cats)',


You should first "explode" the values!

eg.
'value'=>'implode(", ", explode("|",$data->parent_cats))',

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

#7 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,039
  • Joined: 30-October 09
  • Location:UK

Posted 03 March 2010 - 06:48 AM

Thanks mdomba, I figured this out too last night!
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