有一个store的load事件中,调用了另外一个store的load事件所查询出来的值。但是由于异步的问题,取不到值(红字部分)。望大家指点,应该怎么改。先谢过!
//根据设备类型编号,取得设备类型名称
function getEquipmentTypeName(bh){
var resultName;
//连接后台数据
var dataToText = new Ext.data.Store({
url: '../equipmentManage/equipmentPath.aspx',
baseParams: {module: 'getEquipmentTypeName',tx:bh},
reader: new Ext.data.XmlReader(
{record: 'Table', id: 'success'},
['WZFL003']
),
listeners:
{
"load": function()
{
//遍历数据
if (dataToText.getAt(0).id == 'true')
{
resultName= dataToText.getAt(0).data['WZFL003'];
}else{
resultName = "";
}
}
}
});
//加载数据
dataToText.load();
return resultName;
}
//根据物资名称,查询出物资类型路径
function searchData(mc){
var bh;
var f1;
var f2;
//连接后台数据
var dataToText = new Ext.data.Store({
url: '../BackGroundData.aspx',
baseParams: {module: 'getEquipmentPath',tx:mc},
reader: new Ext.data.XmlReader(
{record: 'Table', id: 'success'},
['WZFL001','WZFL003']
),
listeners:
{
"load": function()
{
//遍历数据
if (dataToText.getAt(0).id == 'true')
{
bh = dataToText.getAt(0).data['WZFL001'];
[color=red]f1 = getEquipmentTypeName(bh.substr(0,2));
alert(f1);
f2 = getEquipmentTypeName(bh.substr(0,7));
alert(f2);[/color]
Ext.getCmp("lblPath").setText("(00"+dataToText.getAt(0).data['WZFL001'].substr(0,2)+")"+ f1 + "->" + f2 + "->" +dataToText.getAt(0).data['WZFL003']);
}else{
Ext.MessageBox.alert('查询提示','该物品不存在!');
Ext.getCmp("lblPath").setText("");
}
}
}
});
//加载数据
dataToText.load();
}