【发布时间】:2017-06-18 06:04:31
【问题描述】:
我有一个商店,例如,有 3000 条记录,而我的 pageSize 是 250。我也有来自其中一条记录的唯一值(比如说product_id = 2333),但是这条记录还没有加载,所以 @ 987654322@ 将返回 null。
我的问题是,如何获取尚未加载的记录的索引,以便在获取索引后可以加载正确的页面?
【问题讨论】:
标签: load store record extjs4.2
我有一个商店,例如,有 3000 条记录,而我的 pageSize 是 250。我也有来自其中一条记录的唯一值(比如说product_id = 2333),但是这条记录还没有加载,所以 @ 987654322@ 将返回 null。
我的问题是,如何获取尚未加载的记录的索引,以便在获取索引后可以加载正确的页面?
【问题讨论】:
标签: load store record extjs4.2
你应该使用store的onload方法:
store.on('load',function(component,records){
//here all the records are loaded, so:
component.findRecord('prop',value)//will return your record
//here you can load the page you need
},this,{single:true});
如果记录不存在,则找不到,唯一的方法是等到商店加载完毕。
作为选项传递的属性single:true 只是表示每次在负载侦听器上设置此函数时都会执行一次。
请注意,如果您忽略存储加载将执行您附加的所有侦听器。
如果你想要一个完美的方式来做到这一点:
view.mask('loading the page...');
store.on('load',function(component,records){
component.findRecord('prop',value)//will return your record
//here you can load the page you need
page.load(); //simply example
view.unmask();
},this,{single:true});
store.load();
或
view.mask('loading the page...');
store.load(function(records){
store.findRecord('prop',value)//will return your record
//here you can load the page you need
page.load(); //simply example
view.unmask();
});
【讨论】: