Yii GridView小部件 - 居中对齐分页

时间:2015-09-11 15:20:10

标签: gridview yii2 pager

GridView::widget([
    'dataProvider' => $dataProvider
    'layout' => "{summary}\n{items}\n<div class=''>{pager}</div>",
    'columns' => $columns,
]);

默认情况下,GridView小部件将分页呈现为ul标记,我想将其更改为使用table

4 个答案:

答案 0 :(得分:3)

align="center"可以完成你的工作。见代码。

GridView::widget([
    'dataProvider' => $dataProvider
    'layout' => "{summary}\n{items}\n<div align='center'>{pager}</div>",
    'columns' => $columns,
]);

答案 1 :(得分:2)

GridView::widget([
    'dataProvider' => $dataProvider
    'layout' => "{summary}\n{items}\n<div class='text-center'>{pager}</div>",
    'columns' => $columns,
]);

答案 2 :(得分:0)

对于bootstrap 4小部件,请使用justify-content-center,例如:

GridView::widget([
    'dataProvider' => $dataProvider
    'layout' => "{summary}\n{items}\n<div class='d-flex justify-content-center'>{pager}</div>",
    'columns' => $columns,
]);

<div class="d-flex justify-content-center">
    <?= LinkPager::widget([
        'pagination' => $pagination,
    ]) ?>
</div>

请参见documentation

答案 3 :(得分:0)

对于bootstrap4

GridView::widget([
    'dataProvider' => $dataProvider
    'layout' => "{summary}\n{items}\n<div class='mx-auto'>{pager}</div>",
    'columns' => $columns,
]);