我正在尝试在现有工具栏中添加一个分页工具栏,并使用以下代码隐藏第一个,上一个,下一个,最后一个和刷新按钮。我的问题是我无法获取正确的afterPageText值(总页数)。我在xCP Designer中为结果列表做这个。 Plz帮助。
代码:
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
答案 0 :(得分:0)
错误的总页数或分页信息的差异几乎总是由不正确的服务器响应引起的。
如果我们配置了pageSize:20并且我们想要第2页,那么服务器必须返回正好20条记录,从记录21(基于1的编号)开始,并且必须返回表中正确的记录总数。