dataStore 有数据过来缺无法读取 - Web 开发 / Ajax
var totalScore_Reader = new Ext.data.JsonReader( {
root : 'list',
totalProperty : 'totalCount',
// id : 'id',
successProperty : '@success'
}, [ {
name : 'totalScore',
mapping : 'totalScore'
}]
);
var totalScore_ds=new Ext.data.Store( {
proxy : new Ext.data.HttpProxy( {
url : 'educationalManage/educationalManageAction!getTotalScore',
// params: { 'pageMessage3': 'value' }
}),
reader : totalScore_Reader
});
function totalScore(value,p,record){
var c=value;
totalScore_ds.load({
params: {
'pageMessage3': c }
});
return totalScore_ds.getAt(0).get('totalScore');
}
代码如上, 我firebug 调试时,'educationalManage/educationalManageAction!getTotalScore', 是有数据的。
但是我的最后一句 return totalScore_ds.getAt(0).get('totalScore'); 却读不到数据。 我调试过, dataStore里的lenth为0. 请各位赐教
------解决方案--------------------数据库里面的字段名的大小写跟这里一致了么
------解决方案--------------------异步加载,在 load事件中取值
JScript code
var totalScore_Reader = new Ext.data.JsonReader({
root : 'list',
totalProperty : 'totalCount',
// id : 'id',
successProperty : '@success'
},
[{
name : 'totalScore',
mapping : 'totalScore'
}]
);
var totalScore_ds = new Ext.data.Store({
proxy : new Ext.data.HttpProxy( {
url : 'educationalManage/educationalManageAction!getTotalScore',
// params: { 'pageMessage3': 'value' }
}),
reader : totalScore_Reader,
listeners:{
load:function(){
totalScore_ds.getAt(0).get('totalScore');
}
}
});
function totalScore(value,p,record){
var c = value;
totalScore_ds.load({
params: {'pageMessage3': c}
});
}