douchunsui2395 2014-02-18 17:06
浏览 79
已采纳

在YII应用程序中更改CSS文件不起作用

I am trying to change the styling of the gridview, tableview, & detailview. I found something saying that I should change the config/main.php file to this:

...
// application components
'components'=>array(
    'user'=>array(
        // enable cookie-based authentication
        'allowAutoLogin'=>true,
    ),
    'bootstrap'=>array(
        'class'=>'bootstrap.components.Bootstrap',
    ),
     'widgetFactory'=>array(
        'widgets'=>array(
            'CGridView'=>array(
                'cssFile' => Yii::app()->request->baseUrl.'/css/table_and_grid.css',
            ),

        ),
    ),
...

I have removed the assets folder that is generated by the app, but that didn't help. When I load the view, I can see that the css sheet is being loaded into the header of the page, but none of the styling is working. Why? How do I fix?

  • 写回答

1条回答 默认 最新

  • duanjie9630 2014-02-18 17:56
    关注

    I haven't seen anything about changing the style of CGridView in main config file(main.php), But you can customize CGridView styles with bellow parameters:

    $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'SOME ID',
    'dataProvider'=>$YOUR_DATA_PROVIDET,
    'cssFile'=>'...',
    'baseScriptUrl'=>'...',
    'filterCssClass'=>'...',
    'itemsCssClass'=>'...',
    'pagerCssClass'=>'...',
    'rowCssClass'=>'...',
    'summaryCssClass'=>'...',
    ));
    

    You can change ... with your own. for more information you can check CGridView's Official document on the following link:

    CGridView

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?