First, download the RowExpander plugin, which is used in the example. Next, replace the getBodyContent method with:
getBodyContent : function(record, index, body){
if(!this.enableCaching){
return this.tpl.apply(record.data);
}
var content = this.bodyContent[record.id];
if(!content){
var th = this;
Ext.Ajax.request({
url: this.url,
method: "GET",
params: { id: record.id },
success: function(res) {
var result = eval("("+res.responseText+")");
var content = th.tpl.apply(result);
th.bodyContent[record.id] = content;
body.innerHTML = content;
},
failure: function(res) {
content = "Error loading data";
body.innerHTML = content;
}
});
content = "Loading...";
this.bodyContent[record.id] = content;
}
return content;
}
As you can see, the method signature has been changed, so you have to add body to the method invocation in beforeExpand method. Also, the url to the AJAX service has to be smuggled somehow - I just passed it in the RowExpander initialization parameters.
This probably is not the most elegant solution to this issue - but it has one great advantage: it works :).
No comments:
Post a Comment