Zii Grid View Action Customization


I am using zii grid view, i change action buttons and they are working fine, using this link Click Here

But i have to add button customization in every controller, Is there any other way by that i can manage it via one file? means i dont want to add same code on every page.

Thanks in advance

Hi Alnakar

One of the way is to extend the zii


class MyGridView extends CGridView


//override the appropriate methods, may call the parent::theMethod()


and use ext.yourgridview.yourFilegridview instead of zii.widgets.grid.CGridView

Another way is to create a method in components/conroller.php with argument an array parameters (the parameters of CGridView) merge this array with your custom button and call by itself the CGridView

Thanks KonApaz

Can you provide me some example code.

for gridview you have to extend CButtonColumn in components


class BButtonColumn extends CButtonColumn{

 public  function initDefaultButtons(){

    // make ur changes here 



then use BButtonColumn in ur gridview instead of CButtonColumn

forget the first way I said.

by the second way

In the components/controller just add this code

public function myGridview($arrParams) {

$default = array(







$finalArr = array_merge_recursive($arrParams,$default)

 $this->widget('zii.widgets.grid.CGridView', $finalArr);


Make the yourCButtonColumn as Lal Zada post

and in view file call the above function like












with this, you minimize the code by add only no-default attributes, I didn’t checked the code so test by yourself and tell us if it works! :)


Hi Konapaz


Can you reply on this issue also.