我有一个附加到列表
的商店。该列表还使用 ListPaging
插件来启用分页。在我调用商店的 load
方法(或事件)后,商店将数据加载到列表中,并将请求发送到以下网址 -
http://localhost/mysite/nodelist.php?_dc=1359309895493
&tids=1%2C4%2C2%2C5%2C67&page=1&start=0&limit=10
向下滚动列表并按加载更多...
(由插件附加到列表中)后,商店会向同一网址发送另一个请求,但使用不同的参数,从而启用分页 -
http://localhost/mysite/nodelist.php?_dc=1359310357419
&tids=1%2C4%2C2%2C5%2C67&page=2&start=10&limit=10
现在我想重置商店的 start
和 page
参数的值。我尝试通过在代理上使用 setExtraParam
方法来重置它,但如果我这样做,那么控件不会维护分页 - 这意味着它不会自动更改 页面当我按
和加载更多...
时,start
参数。
那么我该怎么做呢?
这是我商店的示例代码 -
Ext.define('MyApp.store.MyStore', {
extend: 'Ext.data.Store',
requires: [
'Ext.data.reader.Json',
'Ext.data.proxy.Ajax'
],
config: {
autoLoad: false,
model: 'MyApp.model.MyModel',
serverUrl: null,
pageSize: 2,
proxy: {
type: 'ajax',
actionMethods: {
read: 'GET'
},
url: null,
reader: {
type: 'json'
}
},
listeners: {
beforeload: function () {
console.log('Before load');
},
load: function (store) {
// console.log('load');
}
}
}
});
这是 ListView -
list = {
xtype: 'list',
cls: 'myList',
flex: 12,
itemTpl: '{title}',
store: 'MyStore',
plugins: [
{
xclass: 'Ext.plugin.ListPaging',
autoPaging: false
}
],
listeners: {
select: {
scope: this,
fn: this.onSelect
},
swipe: {
scope: this,
element: 'element',
fn: this.onListSwipe
}
}
};
最佳答案
从源码来看,也许你正在寻找currentPage商店的配置?
当您使用 ListPaging 插件加载更多录音时,它所做的就是调用存储中的 nextPage
,然后使用 currentPage
配置调用 loadPage
。如果您将商店中的 currentPage
配置重置回 1,它只会假设起始位置返回到 0,并且页面当然是 1。
关于javascript - Sencha touch 重置存储启动参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14550550/