我有一个 extjs 4.1 网格,其中填充了从服务器加载的 JSON。分页是远程的,每块 25 个项目都以有效 JSON 的形式从服务器正确提供,并在 TotalProperty 中具有正确的值。就加载和分页而言,一切功能都工作正常,只是分页栏中没有页码。 看起来像这样。 好吧...我不允许发布图片...所以这是一个链接 看起来像这样
这是相关代码。如果有助于排除故障,我可以发布其他代码。
var theStore = Ext.create('Ext.data.Store',
{
model: 'SearchResult',
pageSize: 25,
remoteSort: true,
proxy:
{
type: 'ajax',
url: '/Search/SubmitSimpleQuery',
reader:
{
type: 'json',
root: 'Results',
totalProperty: 'totalHits'
},
extraParams:
{
searchText: theSearchText,
beginDate: theBeginDate,
endDate:theEndDate,
collectionMatch:theCollection
}
}
});
theStore.load();
var grid = Ext.create('Ext.grid.Panel',
{
store: theStore,
width: '100%',
height: '100%',
columns:
[
{
text: 'Title',
dataIndex: 'title',
width: '60%'
},
{
text: 'Published Date',
dataIndex: 'pubDate_ymd',
renderer: renderDate
},
{
text: 'Released Date',
dataIndex: 'releaseDate_ymd',
renderer: renderDate
},
{
text: 'From',
dataIndex: 'from',
hidden: true
},
{
text: 'To',
dataIndex: 'to',
hidden: true
}
],
dockedItems: [
{
xtype: 'pagingtoolbar',
dock: 'bottom',
store: theStore,
displayInfo: true,
displayMsg: 'Displaying results {0} - {1} of {2}',
emptyMsg: 'No results'
}]
});
Ext.create('Ext.panel.Panel',
{
bodyPadding:25,
width:'100%',
renderTo:Ext.getBody(),
items:[
grid
]
});
总属性通过 JSON 正确输入 - 例如 108,结果为 5 页。所有分页都有效。当分页到第2页时,
page:2 , start:25, limit: 25
都被传递到服务器,因此ext知道它是什么页面,但它不会进入当前页面框。我是否需要将该页面值设置为代理或存储上的属性?
我被难住了,有一段时间我一直在用头撞这个。
顺便说一下, 这是一个类似的问题 ExtJS 网格面板不显示页码 但它(显然?)修复了将分页栏添加到网格上的停靠项,正如您在上面看到的那样,情况已经如此。
来自 Sencha API 文档:
要使用分页,需要在Store上设置一个pageSize配置, 并在商店第一次时将分页要求传递给服务器 已加载。
store.load({
params: {
// specify params for the first page load if using paging
start: 0,
limit: myPageSize,
// other params
foo: 'bar'
}
});
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.toolbar.Paging
我认为你的问题可能是你手动调用
theStore.load()
而没有任何此类参数。我认为你根本不需要这么称呼。