基于这个线程Sencha 论坛主题 http://www.sencha.com/forum/showthread.php?72216-Grid-asynchronous-update-of-cell-data
我做了一个异步渲染器。
在我的示例中,我想显示记录关联中第一条记录的“名称”值。
“fileRecord_store()”是我的关联存储的名称(通过“hasMany”关联模型创建)
在网格面板中,您可以制作如下渲染器:
{ header: 'Filename', dataIndex: 'Files_id', flex: 2,
renderer: function(value, meta, record, rowIndex, colIndex, store, view) {
var divId = 'my_cell_to_update_' + record.id;
record.columnsNameUpdate(divId);
return String.format("<div id='" + divId + "'>Loading...</div>");
}
},
现在在模型类中我添加了这个函数:
columnsNameUpdate : function(divId){
this.fileRecord_store().on('load', this.updateColumn,this, {divId : divId});
this.fileRecord_store().load();
},
updateColumn : function(store, model, success, options){
this.fileRecord_store().un('load', this.updateColumn,this);
Ext.fly(options.divId).update(store.first().get('filename'));
}
这对我来说工作得很好!