2

这是我在 Yii 中的表:

$this->widget('GridView', array(
        'dataProvider' => $users,
        'itemsCssClass'=>'table',
        'pager' => array(
                'class'             => 'CLinkPager',
                'prevPageLabel'     => 'Previous',
                'nextPageLabel'     => 'Next',
                'htmlOptions'       =>  array(
                                            'class' => 'btn btn-info'
                                        )
        ),
        'columns' => array(
            array(
                'name' => 'User ID',
                'type' => 'raw',
                'value' => 'CHtml::encode($data["id"])'
            ),
            array(
                'name' => 'Username',
                'type' => 'raw',
                'value' => 'CHtml::encode($data["username"])'
            ),
            array(
                'name' => 'Name',
                'type' => 'raw',
                'value' => 'CHtml::encode($data["name"])'
            ),
            array(
                'name' => 'Email',
                'type' => 'raw',
                'value' => 'CHtml::encode($data["email"])'
            ),
            array(
                'name' => 'Role',
                'type' => 'raw',
                'value' => 'CHtml::encode($data["function"])'
            ),
            array(
                'name' => 'Status',
                'type' => 'raw',
                'value' => 'CHtml::encode($data["active"])'
            ),
            array(
                'name'  => 'Action',
                'type'  => 'raw',
                'value' => 'CHtml::link("<button  type=\'button\'  class= \'btn btn-info user_ajax\' data-toggle=\'modal\' data-target=\'#myModal\'>Info</button>")',
            ),
        ),  

    ));

我有一个分页并且它正在工作,我想要的是从引导程序中添加一个类名到生成的每个li中。现在有了这个例子,类btnbtn-info被添加到ul中。我应该改变什么?谢谢

4

2 回答 2

2

最后我找到了一个解决方案:我缺少一个寻呼机属性

'pager' => array(
                'class'             => 'CLinkPager',
                'prevPageLabel'     => 'Previous',
                'nextPageLabel'     => 'Next',
                'header' => '',
                // 'htmlOptions'        =>  array(
                                            // 'class' => 'btn btn-info'
                                        // )
                'previousPageCssClass' => 'btn btn-info btn-sm',
                'selectedPageCssClass' => 'btn btn-warning btn-sm',
                'internalPageCssClass' => 'btn btn-info btn-sm',
                'firstPageCssClass' => 'btn btn-info btn-sm',
                'nextPageCssClass'  => 'btn btn-info btn-sm',
        ),
于 2015-01-12T12:54:34.877 回答
0

尝试使用寻呼机'hiddenPageCssClass''selectedPageCssClass'属性

'pager' => array(
                'class'             => 'CLinkPager',
                'prevPageLabel'     => 'Previous',
                'nextPageLabel'     => 'Next',
                'hiddenPageCssClass'=>'notselected', // set it for page buttons that are not selected
                'selectedPageCssClass'=>'selected', // set it for the current page button
                'htmlOptions'       =>  array(
                                            'class' => 'btn btn-info'
                                        )
        ),

要查看更多属性,请单击此处

于 2015-01-12T12:45:08.240 回答