1

请在这里查看屏幕截图我正在尝试在现有工具栏中添加一个分页工具栏,并使用以下代码隐藏第一个、上一个、下一个、最后一个和刷新按钮。我的问题是我无法获取正确的 afterPageText 值(总页数)。我正在为 xCP Designer 中的结果列表执行此操作。请帮忙。

代码:

    
Ext.define('Override.toolbar.Paging', {
override: 'Ext.toolbar.Paging',
hideFirstButton: false,
hidePrevButton: false,
hideBeforePageText: false,
hidePageNumberField: false,
hideAfterPageText: false,
hideNextButton: false,
hideLastButton: false,
hideRefreshButton: false,   
getPagingItems: function() {
        var me = this;
        return [{
        itemId: 'first',
        tooltip: me.firstText,
        overflowText: me.firstText,
        iconCls: Ext.baseCSSPrefix + 'tbar-page-first',
        hidden: me.hideFirstButton,
        disabled: true,
        handler: me.moveFirst,
        scope: me
        }, {
        itemId: 'prev',
        tooltip: me.prevText,
        overflowText: me.prevText,
        iconCls: Ext.baseCSSPrefix + 'tbar-page-prev',
        hidden: me.hidePrevButton,
        disabled: true,
        handler: me.movePrevious,
        scope: me
        }, {
        xtype: 'tbseparator',
        hidden: me.hideFirstButton && me.hidePrevButton
        }, {
        xtype: 'tbtext',
        text: me.beforePageText,
        hidden: me.hideBeforePageText
        }, {
        xtype: 'numberfield',
        itemId: 'inputItem',
        name: 'inputItem',
        hidden: me.hidePageNumberField,
        cls: Ext.baseCSSPrefix + 'tbar-page-number',
        allowDecimals: false,
        minValue: 1,
        hideTrigger: true,
        enableKeyEvents: true,
        keyNavEnabled: false,
        selectOnFocus: true,
        submitValue: false,        
        isFormField: false,
        width: me.inputItemWidth,
        margins: '-1 2 3 2',
        listeners: {
        scope: me,
        keydown: me.onPagingKeyDown,
        blur: me.onPagingBlur
            }
        }, {
            xtype: 'tbtext',
            itemId: 'afterTextItem',
            hidden: me.hideAfterPageText,
            text: "of {0}"
        }, {
            xtype: 'tbseparator',
            hidden: me.hideNextButton && me.hideLastButton
        }, {
            itemId: 'next',
            tooltip: me.nextText,
            overflowText: me.nextText,
            iconCls: Ext.baseCSSPrefix + 'tbar-page-next',
            hidden: me.hideNextButton,
            disabled: true,
           handler: me.moveNext,
            scope: me
        }, {
            itemId: 'last',
            tooltip: me.lastText,
            overflowText: me.lastText,
            iconCls: Ext.baseCSSPrefix + 'tbar-page-last',
            hidden: me.hideLastButton,
            disabled: true,
            handler: me.moveLast,
            scope: me
        }, {
            xtype: 'tbseparator',
            hidden: me.hideRefreshButton
        }, {
            itemId: 'refresh',
            hidden: me.hideRefreshButton,
            tooltip: me.refreshText,
            overflowText: me.refreshText,
            iconCls: Ext.baseCSSPrefix + 'tbar-loading',
            handler: me.doRefresh,
            scope: me
        }];
    }
});
xcp.widget.grid.ResultsListGrid.override({
        initComponent: function () {
            var me = this;
            this.dockedItems = [
			{
                xtype: 'toolbar',
				//store: me.store,
                dock: 'bottom',
				height: '45px',
                items: [
                    //'->',//right alight the button
					{
                xtype: 'xcp_pagingtoolbar',
                store: me.store,
				//flex: true,
                dock: 'bottom',
                displayInfo: true
            },'->',
			{
			xtype: 'pagingtoolbar',
            store: me.store,
			displayInfo: false,
				hideRefreshButton: true,
                hideFirstButton: true,
                hideLastButton: true,
                hidePrevButton: true,
                hideNextButton: true,
				//disabled: true
			}
                    ]
            },				
			];
            this.callParent();
        }
    }
);

谢谢。-SS

4

1 回答 1

0

不正确的总页数或分页信息中的任何差异几乎总是由不正确的服务器响应引起的。

如果我们配置了 pageSize:20 并且我们想要第 2 页,服务器必须准确返回 20 条记录,从记录 21(基于 1 的编号)开始,并且必须返回表中正确的记录总数。

于 2015-01-12T10:18:55.677 回答