Yii Framework Forum: CButtonColumn different for rows in CGridView - Yii Framework Forum

Jump to content

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

CButtonColumn different for rows in CGridView Rate Topic: -----

#1 User is offline   fhelix72 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 22-April 09
  • Location:Italy - Vicenza

Posted 16 February 2010 - 03:34 AM

Hello, I would like to use CGridView and CButtonColumn, the buttons should be different for each row conditioned by the data in the row.
So I could have in the first row "Show Update Delete" in the second only "Show" and so on..

Is this possible?
thanks
0

#2 User is offline   yiimann 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 19-December 09

Posted 17 February 2010 - 03:05 PM

Maybe by attaching a behaviour to CDataColumn you could change the buttons template for each row
0

#3 User is offline   Maurizio Domba Cerin 

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

Posted 18 February 2010 - 07:03 AM

I replayed you in this post:

http://www.yiiframew...__fromsearch__1
Find more about me.... btw. Do you know your WAN IP?
0

#4 User is offline   luis diego 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 02-February 10
  • Location:Costa Rica

Posted 19 February 2010 - 11:00 AM

Hello,

thanks for the extension. It helped me to that I was looking for. Hide the update and edit buttons of all rows.

By the way, which is the function of the property visible from CButtonColumn class? Because for me it don't work or I don't know how to use it.
0

#5 User is offline   Maurizio Domba Cerin 

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

Posted 19 February 2010 - 05:12 PM

View Postluis diego, on 19 February 2010 - 11:00 AM, said:

Hello,

thanks for the extension. It helped me to that I was looking for. Hide the update and edit buttons of all rows.

By the way, which is the function of the property visible from CButtonColumn class? Because for me it don't work or I don't know how to use it.



Note that this extension is better suited for the need to have different buttons in different rows... if you want to omit the update button in all rows than it is faster to just set the template property - http://www.yiiframew...template-detail

the visible property is for the custom buttons - http://www.yiiframew...#buttons-detail
Find more about me.... btw. Do you know your WAN IP?
0

#6 User is offline   toall 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 14-March 11

Posted 04 March 2013 - 04:07 AM

I resolved this problem like below:
In this example visibility of delete button depends on result of function CzyTypJestDowiazany().


CGridViewVidget :

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'typy-grid',
'dataProvider'=>$DataProvTU,
'columns'=>array('nazwa',
array('class'=>'CButtonColumn',
'htmlOptions'=>array('style'=>'float:left;'),
'template'=>'{update} {delete}',
'buttons'=>array(
'deleteButtonVisible'=>'User::canDelete($data->id)',
'delete'=>array('url'=>'CController::createUrl("/typyUzytkownikow/delete",array("id"=>$data->primaryKey))',
'visible'=>'CzyTypJestDowiazany($data->id)',
),
),
),
),
));


And now function CzyTypJestDowiazany. You can put it in Controler or in some other file included in index.php.


function CzyTypJestDowiazany($id_typu){

// Put Your code here ...
// whatever you want
// and return false or true depend of result of your code.

if ($RESULT) {return true;}
else {return false;}
}
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