使用ExtJS 5.1,当我加载网格面板时,它在分页工具中显示正确的分页号。但在页面加载期间,它始终显示第1页,共5页。上一个和下一个按钮被禁用。
#
var store = new Ext.data.Store({
autoLoad: {params:{start: 0, limit: 5}},
pageSize: 5,
remoteSort: true,
model: 'TenantDetails',
proxy: {
type: 'ajax',
enablePaging : true,
url: 'http://localhost:8080/restcountries-dev/rest/page/v0.5/tenant',
reader: new Ext.data.JsonReader({
type: 'json' ,
totalProperty:15,
rootProperty:'tenant'
})
},
listeners:{
load:function(store){
Ext.getCmp('tenant_detail_grid').getSelectionModel().select(0, true);
}
}
});
#
分页工具栏的定义如下。
Ext.create('Ext.PagingToolbar', {
store: store,
displayInfo: true,
displayMsg: '{0} - {1} of {2}',
emptyMsg: "No topics to display"
})
#
不知道我到底错过了什么。谢谢
答案 0 :(得分:0)
您的代码看起来是正确的。这是我的分页的一个有效例子。
initComponent: function () {
var me = this;
me.store = Ext.create('Desktop.children.store.childrenStore');
me.columns = [
{
text : 'Nachname',
dataIndex: 'lastName',
flex: 1
},
{
text : 'Vorname',
dataIndex: 'firstName',
flex: 1
},
{
text : 'Gruppe',
//name: 'group_id',
dataIndex: 'groupName',
flex: 1
},
{
text : 'Faktor',
//name: 'group_id',
dataIndex: 'factorName',
flex: 1
},
{
xtype: 'datecolumn',
text : 'Geburtsdatum',
dataIndex: 'birthdate',
format: 'd.m.Y',
flex: 1
},
{
text : 'Status',
//name: 'group_id',
dataIndex: 'isActive',
flex: 1
},
{
xtype: 'actioncolumn',
width: 60,
menuDisabled: true,
items: this.LoadControlBar()
}
];
me.plugins = [{
ptype:'saki-gridsearch'
,searchText: 'Suchen'
,autoTipText: 'Mindestens zwei Zeichen'
,selectAllText: 'Selektiere alle'
}];
me.bbar = me.paging = Ext.create('Ext.toolbar.Paging', {
store:me.store
,displayInfo:true
});
me.tbar = [
{
xtype: 'button',
id:'child_btn_add',
text:'Kind hinzufügen',
tooltip:'Neues Kind hinzufügen',
iconCls:'add',
hidden: (CheckPermission('Desktop.children.view.Mainwindow') != "WRITE"),
handler:function(view, e){
this.fireEvent('AddChildren', view, e);
}
},
{
xtype: 'button',
id: 'btnChildExport',
text: 'Liste exportieren',
tooltip: 'Spezifische Liste exportieren',
iconCls: 'exportList',
handler: function(view, e){
this.fireEvent('ExportList', view, e);
}
}
];
me.callParent();
},
存储
Ext.define('Desktop.children.store.childrenStore', {
extend: 'Ext.data.Store',
id: 'childrenStore',
alias: 'widget.childrenStore',
requires: [
'Desktop.children.model.childrenModel',
'Ext.data.proxy.Memory',
'Ext.data.reader.Array'
],
model: 'Desktop.children.model.childrenModel',
//autoLoad:true,
pageSize: 10,
proxy:
{
type:'ajax',
enablePaging: true,
url:'resources/php/json.php',
headers: { 'Content-Type': 'application/json' },
extraParams:{
data : JSON.stringify({
module : "children",
action : "load",
jsonObject : null}),
start: 0,
limit: 10,
},
reader:{
type:'json',
rootProperty: 'Anfang'
}
},
sorters: [{
property : 'lastName',
direction:'ASC'
}],
});