重写 Ext.toolbar.Paging 扩展功能

直接代码,放项目overrides文件夹中即可

//重写类 分页插件
//汉化
//默认下方布局
//默认显示额外信息
//当删除数据时,处理页面变化
Ext.define("override.toolbar.Paging", {
    override: "Ext.toolbar.Paging",
    displayMsg: '显示 {0} - {1} 条,共 {2} 条',
    emptyMsg: '没有要显示的数据',
    beforePageText: '第',
    afterPageText: '页,共 {0} 页',
    firstText: '第一页',
    prevText: '上一页',
    nextText: '下一页',
    lastText: '最后一页',
    refreshText: '刷新',
    dock: 'bottom',
    displayInfo: true,
    //新增remove监听
    getStoreListeners: function () {
        return {
            beforeload: this.beforeLoad,
            load: this.onLoad,
            exception: this.onLoadError,
            remove: this.onRemoveRecords
        };
    },
    //当删除数据时
    onRemoveRecords: function (store, records) {
        var me = this,
        //当前页数据总数
        count = store.getCount(),
        //当前页码
        currentPage = store.currentPage,
        //页面总数
        pageCount = me.getPageData().pageCount,
        //数据总数
        totalCount = store.getTotalCount();
        //当前页已经没有数据
        if (count == 0) {
            if (pageCount == currentPage) {
                //如果是最后一页,显示上一页
                me.movePrevious();
            } else {
                //不是最后一页,刷新
                me.doRefresh();
            }
        } else {
            //重新设置数据总数
            store.totalCount = totalCount - records.length;
            //刷新页面
            me.updateInfo();
        }
    }
});
原文地址:https://www.cnblogs.com/mlzs/p/5595765.html