zoukankan      html  css  js  c++  java
  • 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();
            }
        }
    });

  • 相关阅读:
    iOS 11: CORE ML—浅析
    Android 平台 Native 代码的崩溃捕获机制及实现
    H5直播避坑指南
    Mac系统升级至OS X Mavericks后Genymotion出现的问题及解决方法
    Android 4.4 KitKat终于支持录屏(Screen Recording)了!
    Android开发者资源大汇总
    用AndroidSDK中的Face Detector实现人脸识别
    [Android设计模式]Android退出应用程序终极方法
    ActionBarCompat 教程-实现Action Bar
    使用Roboguice依赖注入规划Android项目
  • 原文地址:https://www.cnblogs.com/barryhong/p/1779742.html
Copyright © 2011-2022 走看看