FineUI/FineUI.Examples/extjs_builder/js/ux/SimplePagingToolbar.js

72 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-05-19 14:45:47 +08:00
Ext.define('Ext.ux.SimplePagingToolbar', {
extend: 'Ext.toolbar.Paging',
alias: 'widget.simplepagingtoolbar',
cls: 'x-toolbar-paging',
// Override parent
initComponent: function () {
var me = this;
me.store = Ext.Object.merge({}, me.store, {
getCount: function () {
return me.f_recordCount;
},
currentPage: me.f_pageIndex + 1
});
me.callParent();
},
// Override parent
getPagingItems: function() {
var items = this.callParent();
// Remove refresh and separator items.
return items.slice(0, items.length - 2);
},
// Override parent
getPageData: function () {
var fromRecord = 0, toRecord = 0;
if (this.f_databasePaging) {
fromRecord = (this.f_pageIndex * this.f_pageSize) + 1;
toRecord = fromRecord + this.f_pageSize - 1;
} else {
fromRecord = this.f_startRowIndex + 1;
toRecord = this.f_endRowIndex + 1;
}
if (toRecord > this.f_recordCount) {
toRecord = this.f_recordCount;
}
return {
total: this.f_recordCount,
currentPage: this.f_pageIndex + 1,
pageCount: this.f_pageCount <= 0 ? 1 : this.f_pageCount,
fromRecord: fromRecord,
toRecord: toRecord
};
},
f_update: function (configs) {
Ext.Object.merge(this, configs);
this.store.currentPage = this.f_pageIndex + 1;
this.onLoad();
2017-09-05 10:49:48 +08:00
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>˷<EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>¼<EFBFBD><C2BC><EFBFBD> f_startRowIndex <20><> f_endRowIndex
if (!this.f_databasePaging) {
var startRowIndex = this.f_pageSize * this.f_pageIndex;
var endRowIndex = (this.f_pageIndex + 1) * this.f_pageSize - 1;
if(endRowIndex > this.f_recordCount - 1) {
endRowIndex = this.f_recordCount - 1;
}
this.f_startRowIndex = startRowIndex;
this.f_endRowIndex = endRowIndex;
}
2015-05-19 14:45:47 +08:00
}
});