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();
            }
        }
    });

  • 相关阅读:
    Spring Security配置logout地址
    flex布局
    视口的学习笔记
    box-sizing属性
    css清除浮动
    line-height的理解
    position和float小结
    css居中方法小结
    margin重叠
    浅谈负margin
  • 原文地址:https://www.cnblogs.com/barryhong/p/1779742.html
Copyright © 2011-2022 走看看