yii2 linkpager ajax,Yii2扩展 - LinkPager 带分页大小

安装:

2. 在程序根目录右键(同时按住"shift")打开 "Use Composer here", 执行命令(会同时更新yii2的核心库):composer require --prefer-dist liyunfang/yii2-widget-linkpager

使用:

1. 在输出 GridView 时配置如下属性:GridView::widget([

'dataProvider' => $dataProvider,

'columns' => [

……

],

'filterSelector' => "select[name='" . $dataProvider->getPagination()->pageSizeParam . "'], input[name='" . $dataProvider->getPagination()->pageParam . "']",

'pager' => [

'class' => \liyunfang\pager\LinkPager::className(),

'template' => '{pageButtons} {customPage} {pageSize}',

'pageSizeList' => [10, 20, 30, 50],

'customPageWidth' => 50,

'customPageBefore' => ' 跳转到第 ',

'customPageAfter' => ' 页 ',

],

]);

2. 在对应的控制器中添加:$searchModel = new ArticleSearch();

$pageSize = isset($_GET['per-page']) ? intval($_GET['per-page']) : 2;

$dataProvider = new ActiveDataProvider([

'query' => $searchModel->find()->orderBy('sort desc, publish_time desc'),

'pagination' => [

'pagesize' => $pageSize,

]

]);

3. "pager"的配置参数:template string 分页栏布局, 默认为"{pageButtons} {pageSize}"

pageButtons 页码列表

customPage 第几页

pageSize 页大小下拉框

pageSizeList array 页大小下拉框值, 默认为"[10, 20, 30, 50]"

pageSizeMargin string "pageSize"的 css 属性, 默认为"margin-left:5px;margin-right:5px;"

pageSizeOptions string "pageSize"的 html 属性, 默认为"['class'=>'form-control', 'style'=>'display:inline-block;width:auto;margin-top:0px;']"

customPageBefore string "customPage"之前的文本, 默认为空

customPageAfter string "customPage"之后的文本, 默认为空

customPageWidth integer "customPage"文本框的宽度, 单位为"px", 默认为"80"

customPageMargin string "customPage"的 css 属性, 默认为空

customPageOptions string "customPage"的 html 属性, 默认为"['class'=>'form-control', 'style'=>'display:inline-block;margin-top:0px;']"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值