Yii Assets


I working in a project where i have to deploy project files in installer. but i have make some changes in zii grid view layout.

So each and every time when i install my project, zii grid layout change to its default layout (blue header).

Please anyone can help me how to layout zii grid view permanently means it will not change its layout on new server

Thanks in advance :)

Dear Friend

We can copy the folder framework/zii/widgets/grid/gridview.

Put the contents inside the webroot/css folder.

You can remove the jquery.yiigridview.js inside the folder.

You can make modification there in styles.css file.

Now in admin.php we have set the cssFile Path.

<?php $this->widget('zii.widgets.grid.CGridView', array(







But every admin.php, we have to do this modification if you want the changes and changes to persist.


You could also simply created a new class like this, and use that instead of CGridView



class GridView extends CGridView


public &#036;cssFile = 'yourStyle.css';



Hi Coksnuss,

Can you elaborate me more, means how can i call this $cssFile variable in zii grid.

What exactly do you need to know?

From what I have understood, you’ve changed the source code @framework/zii/widgets/grid/CGridView.php and searching for a way to do this changes without changing the framework files. Am I correct with that?

If I am correct: What exactly did you changed?

No, in asset folder there are some files for zii grid view, i changed that but when i upload the same project on different server in asset folder new folder is generate for zii.

I just want a way by that if i fixed the layout of grid view then i dont need to change it on different servers.


Ah ok, I see. Well then you can use my provided solution without any problems.

The approach in detail (assuming default paths)


return array(


'import' => array('application.components.*'),




class GridView extends CGridView


    public function init()


        $this->cssFile = Yii::app()->baseUrl . '/css/gridview.css';





Just copy&paste the content of your modified style.css in here.

Now simply search and replace all calls of

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


$this->widget('GridView', array(...));


Thanks :)

Hi Coksnuss

One more help, in zii grid, when i enter something in filter textboxes, loading image is show but it does not filter the result, what is the issue ?

Thanks in advanced


As it looks like this was not stated explicitally:

  1. You should not manually change any file under the ‘assets’ folder. The files there are copied/generated. At best you should make sure that your setup is still working after deleting the entire assets contents!

  2. You can specify your own ‘css’ file as indicated above by specifying this as an option to the gridview, or you can create a CSS file that you also load in which you create more specific rules. One technique I use is to add ‘body’ in tront of the rule - the body is always available and it makes the rule more specific.


".gridview .abc { color: green; }" would become "body .gridview abc {color: red; }" if you prefer to use read for ".gridview .abc" rather than the default green.

Hi Coksnuss

Can you tell me also how can i change button path of zii grid view


please refer to the API Documentation:




for example:


 'class' => 'CButtonColumn',

 'viewButtonUrl' => 'Yii::app()->controller->createUrl("yourViewAction", array("parameter1" => "value1"))',