extJS 4.2 自定义分页

Ext.define("Ext.ux.CustomSizePagingToolbar", {// 定义的名字要和文件的名字大小写一样
    extend : "Ext.toolbar.Paging",
    xtype:'customSizePagingToolbar',
    alias : "widget.custompaging",// 别名
    beforSizeText : "每页",
    afterSizeText : "条",
    getCustomItems : function() {
        var me = this;
        // 自定义customComStore
        var customComStore = Ext.create("Ext.data.JsonStore", {
            fields : [ "customPageSize" ],
            data : [ {
                customPageSize : "10"
            }, {
                customPageSize : "20"
            }, {
                customPageSize : "50"
            } ]
        })
        // 自定义customComboBox
        var customComboBox = Ext.create("Ext.form.field.ComboBox", {
            itemId : "customComboId",
            store : customComStore,
            queryMode : "local",
            displayField : "customPageSize",
            valueField : "customPageSize",
            enableKeyEvents : true,// 感应键盘事件
            width : 60,
            listeners : {
                scope : me,// 作用域
                select : me.onCustomSelect,
                keydown : me.onCustomKeyDown,
                blur : me.onCustomBlur
            }
        });
        // - 表示分割线,> 表示右边显示
        return [ "-", me.beforSizeText, customComboBox, me.afterSizeText ];
    },
    onCustomSelect : function(combo, records, eOpts) {// 选择事件触发
        var me = this;
        me.store.pageSize = records[0].data.customPageSize;
        me.store.loadPage(1);// 默认加载第一页
    },
    onCustomKeyDown : function(field, e, eOpts) {// 按键事件触发
        var me = this;
        var k = e.getKey();
        if (k == e.ENTER) {
            e.stopEvent();// 停止其他事件
            me.store.pageSize = me.child("#customComboId").getValue();
            me.store.loadPage(1);
        }
    },
    onCustomBlur : function(combo, the, eOpts) {// 失去焦点事件
        var me = this;
        me.child("#customComboId").setValue(me.store.pageSize);
    },
    // 初始化界面组件
    initComponent : function() {
        var me = this;
        Ext.apply(me, {// 应用、附加
            items : me.getCustomItems()
        });
        me.callParent(arguments);
        me.child("#customComboId").setValue(me.store.pageSize);// 初始化赋值
    }
})
 
引用:
bbar: {
    xtype:'customSizePagingToolbar',
    store: store,
    displayInfo: true,
    displayMsg: '显示{0}-{1}条,共{2}条',
    emptyMsg: "没有数据"
},

 

                
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值