ExtJS 网格分页:下一个按钮被禁用!
我创建了一个带有分页工具栏的基本网格。由于某种原因,当我在索引 0 处加载时,“下一页”按钮被禁用,即使文本显示“显示第 1 页,共 5 页”。如果我在商店的加载参数中选择任何高于 0 的值,它允许我向前和向后翻页,但它无法正确显示最大页数,如果我返回到第一页,则下一个按钮是一次再次禁用。
有什么想法吗?
function getBugGrid(activityPanelWrapper){
var pageSize = 5;
var bugStore = new Ext.data.JsonStore({
reader: new Ext.data.JsonReader({
totalProperty: 'total_count'
}),
autoLoad: {params:{start: 0, limit: pageSize}},
autoDestroy: true,
url: '/bugs/fetch',
idProperty: 'id',
region: 'center',
root: 'data',
storeId: 'bugStore',
fields: [...]
});
var columnModel = new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
},
columns: [...]
});
return new Ext.grid.GridPanel({
region: 'center',
store: bugStore,
colModel: columnModel,
trackMouseOver:false,
loadMask: true,
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
listeners: {
rowclick: {
fn: function(grid, rowIndex, event) {
var bug_id = grid.store.getAt(rowIndex).id;
Ext.getCmp('activity-panel').load(activity_lines_path(bug_id));
}
}
},
bbar: new Ext.PagingToolbar({
pageSize: pageSize,
store: bugStore,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
});
}
JSON 响应:
{"data":[{ bug 1 },{ bug 2 },{ bug 3 },{ bug 4 },{ bug 5 }],
"errors":{},
"total_count":25}
I created a basic grid that has a paging toolbar. For some reason when I load up at index 0, the Next Page button is disabled, even though the text says "Displaying page 1 of 5". If I choose anything higher than 0 in the load params for the store, it allows me to page forward and back, but it does not properly display the max # of pages and if I go back to the first page, the next button is once again disabled.
Any ideas?
function getBugGrid(activityPanelWrapper){
var pageSize = 5;
var bugStore = new Ext.data.JsonStore({
reader: new Ext.data.JsonReader({
totalProperty: 'total_count'
}),
autoLoad: {params:{start: 0, limit: pageSize}},
autoDestroy: true,
url: '/bugs/fetch',
idProperty: 'id',
region: 'center',
root: 'data',
storeId: 'bugStore',
fields: [...]
});
var columnModel = new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
},
columns: [...]
});
return new Ext.grid.GridPanel({
region: 'center',
store: bugStore,
colModel: columnModel,
trackMouseOver:false,
loadMask: true,
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
listeners: {
rowclick: {
fn: function(grid, rowIndex, event) {
var bug_id = grid.store.getAt(rowIndex).id;
Ext.getCmp('activity-panel').load(activity_lines_path(bug_id));
}
}
},
bbar: new Ext.PagingToolbar({
pageSize: pageSize,
store: bugStore,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
});
}
JSON response:
{"data":[{ bug 1 },{ bug 2 },{ bug 3 },{ bug 4 },{ bug 5 }],
"errors":{},
"total_count":25}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有读取 JsonReader 中的 TotalProperty...
您需要将此配置添加到您的 autoLoad...
您还可以在 JSON 存储中定义一个 JSON 读取器:
});
You are not reading the TotalProperty in the JsonReader...
You need to add this config to your autoLoad...
You can also define a JSON reader in your JSON store:
});