【发布时间】:2012-03-18 13:55:02
【问题描述】:
我正在创建和加载一个商店。但是,当我尝试使用 first() 方法从第一个模型实例中检索记录时,它失败了。
代码如下:
var getCaseId = function(){
var csId;
//form url
var getCaseIdStore = Ext.create('Roa.store.district.Requests', {
model: 'Roa.model.district.Requests',
proxy: {
type: 'ajax',
url : 'http://localhost:8080/roa/MongoDataService/requests?etc',
method: 'GET',
reader: {
type: 'json',
root: 'requests'
}
},
autoLoad: true
});//end create store
console.log('request store created');
getCaseIdStore.load({
scope: this,
callback: function(records,operation,success){
if(success){
//var req = getCaseIdStore.first();
//var csId = req.get('caseId');
//console.log('csId==>'+csId);
//return csId;
}//end if
}//end callback
});//end store load
var req = getCaseIdStore.first();
if (req != undefined){
csId = req.get('caseId');
console.log('return csId==>'+csId);
return csId;
}
else{
console.log('your attempt failed');
}
};//end function
请好心人指教。
-TU
【问题讨论】: