PagingToolbar 设置每页条数

Ext.PagingToolbar默认没办法设置每页条数。

如图:

image

如果想让用户自己定义每页条数:

如图:

image

网上找了半天竟然找不到相应的解决办法,只能自己去写个控件。

代码:

/*!
* HlJS Library 1.0.0
* Copyright(c) 2006-2010 HZZY, LLC
* lighthong@sina.com.cn
* http:
*/
/**
* @class Hljs.component.HlPagingToolbar
* 在Ext.PagingToolbar的基础上增加了自己设置每页多少条的功能
* 20100717 创建
*/
Ext.namespace("Hljs.component");

Hljs.component.HlPagingToolbar = Ext.extend(Ext.PagingToolbar, {
    displayInfo: true,
    displayMsg: '显示第 {0} 条到 {1} 条记录,共 {2} 条',
    emptyMsg: "无记录",
    initComponent : function(){
        var pageSizeItems = [
                     '每页',
                     this.inputItem = new Ext.form.NumberField({
    cls: 'x-tbar-page-number',
    allowDecimals: false,
    allowNegative: false,
    enableKeyEvents: true,
    maxValue: 500,
    maxText: '每页不允许超过500条',
    selectOnFocus: true,
    value: this.pageSize,
    submitValue: false,
    listeners: {
        scope: this,
        keydown: this.onHlPagingKeyDown,
        blur: this.onHlPagingBlur
    }
                     }),'条'
                     ];
         var userItems = this.items || [];
         this.items = userItems.concat(pageSizeItems);
         Hljs.component.HlPagingToolbar.superclass.initComponent.call(this);
    },
    onHlPagingKeyDown: function(field, e){
        if(field.isValid()){
            var k = e.getKey();
             if (k == e.RETURN) {
                    e.stopEvent();
                    this.pageSize = field.getValue();
                    this.doRefresh();
             }
        }
    },
    onHlPagingBlur: function(field){
        if(field.isValid()){
            this.pageSize = field.getValue();
            this.doRefresh();
        }
    }
});

转载于:https://www.cnblogs.com/barryhong/archive/2010/07/17/1779742.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值