我有一个渲染器函数,它必须从商店加载一些数据才能返回一个值,但我一直无法弄清楚如何将我想要的内容返回到网格列。
{header: 'Manager First Name',
renderer: function(value, meta, record){
record.Managers().load({
scope: this,
callback: function(managers, operation, success){
if(success && managers){
managers[0].getPerson({
scope: this,
callback: function(person, operation){
if(person){
return person.get("firstName");
} else {
console.error('This manager doesn\'t have a person record.');
return '';
}
}
});
} else {
console.error('No manager record for the shop '+record.getId());
}
}
});
}}
我试过将 return
放在 load
和 getPerson
函数前,但没有成功。我也想过触发一个事件,但我不确定那会是什么样子。有什么想法吗?
最佳答案
我会在渲染主网格之前加载您的附加信息。这样在 renderer() 函数中您将使用已经加载的数据。
否则您的渲染器函数将被调用多次,并且您将在异步加载您的商店时遇到一些大麻烦。
关于javascript - ExtJS Grid 渲染器函数中的回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10179083/