Configure widget

Is it possible to "pre-configure" a widget in a view file like this:


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

Inside the config/main.php file???

For example, I would like to use a specific css file for all my Grid views, so I don’t need to do it inside every view I use them. That would look something like:




...

components => array(

    'zii.widgets.grid.CGridView' => array(

        'cssFile' => Yii::app()->request->baseUrl. '/css/grid.css',

    ),

),

...

what about extending?

That is possible, but I just see if it is possible with minimal effort :)

If you extend your controllers from one main controller (e.g. class Controller), you can create a Controller.widgetGridView() method, which will call widget() method with needed params. Anyways, every “good” way requires extending :)