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