我一直试图设置一个页面大小,以便我的应用程序运行得更快。我正在从一个巨大的xml文件(数千行)中读取数据,我想一次只使用ListPaging插件加载一个“页面”。
这是我的清单:
xtype : 'list',
plugins: {
xclass: 'Ext.plugin.ListPaging',
autoPaging: true,
loadMoreText : 'Loading more...',
noMoreRecordsText : 'loaded'
},
store : 'mainStore',
height : '100%',
layout : 'fit',
id: 'myList',
flex : 5,
itemTpl : "foo"这是我的店:
config: {
model : 'myApp.model.foo',
storeId: 'mainStore',
autoLoad: true,
//currentPage: 1,
//buffered: true,
pageSize: 15,
proxy : {
type : "ajax",
url : 'resources/images/data/fooBar.xml',
startParam: 'offset',
reader : {
type : "xml",
rootProperty : 'foo',
record : 'bar'
}
}
}然而,当我运行这个程序时,我得到的只是“加载更多.”文本位于整个列表的底部(不是向下15个项),然后它只再次加载相同的xml数据,但这次只是将其连接到整个“列表”的末尾。
如何设置页面大小,使每个“页面”只显示15项左右,然后当我滚动到列表的底部(即15项长)时,我会将接下来的15项连接到最后的15项,使总共30项显示。以此类推。
使用Sencha Touch 2.4.1
更新:这里是配置:
config: {
model : 'c17App.model.approaches',
storeId: 'mainStore',
autoLoad: true,
pageSize: 15,
proxy : {
type : "ajax",
url : 'resources/images/data/approach_all.xml',
total: 17,
start: 1,
limit: 15,
reader : {
type : "xml",
rootProperty : 'approaches',
record : 'approach',
totalProperty: 'total'//maybe needs to be a number?
}
}
}发布于 2015-03-25 06:49:24
从您提供的场景来看,您的web服务似乎不符合Sencha的ListPaging插件。pageSize是你在store config中正确使用的。
config: {
pageSize: 15,
......
}您的API响应应该具有以下属性以支持ListPaging
total:这个字段/属性将与您的API一起出现。使用此值,插件将决定应用程序是否已到达列表的末尾。start:这是由Headers中的插件发送的,远程代理将知道从哪个索引位置开始数据获取。limit:这只是你的pageSize。它也是由Headers中的插件发送的,远程代理将知道它应该从start索引中获取多少数据。因此,请检查您的api响应是否有total、start和limit参数。如果存在,只需将此读取器添加到代理中:
reader: {
type: 'xml', // 'json' if the api is giving response in json format
rootProperty: 'xyz', // Depends on your api response.
totalProperty: 'total'
}你的问题就会解决。请随意要求任何其他的澄清。
--------------------------------------EDIT
“total”、“start”和“limit”应该出现在api响应中,以支持列表分页。您不必在代理中显式地发送它(正如您在编辑部分中发送的那样)。
https://stackoverflow.com/questions/29240460
复制相似问题