这是我在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>")',
),
),
));
我有一个分页,它正在工作,我想要的是从bootstrap添加一个类名到生成的每个 li 。现在,通过此示例, btn 和 btn-info 类将添加到 ul 。我应该改变什么? THX
答案 0 :(得分: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'
)
),
要查看更多属性,请点击here
答案 1 :(得分:0)
最后我找到了一个解决方案:我错过了一个寻呼机属性
'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',
),