1 AjaxRowExpander = function(config, tocURL){ 2 AjaxRowExpander.superclass.constructor.call(this, config, tocURL); 3 this.tocURL = tocURL; 4 this.enableCaching = true; 5 this.addEvents({ 6 updated : true 7 }); 8 } 9 10 Ext.extend(AjaxRowExpander, Ext.grid.RowExpander, { 11 getBodyContent : function(record, index){ 12 var body = '<div id="tmp-' + record.id + '"><span style="margin-left: 45px;">Loading...</span></div>'; 13 Ext.Ajax.request({ 14 url: this.tocURL + record.id, 15 disableCaching: false, 16 success: function(response, options) { 17 var parent = Ext.get('tmp-' + options.objId); 18 function updatedCallback() { 19 this.fireEvent('updated', this, parent); 20 } 21 parent.update(response.responseText, false, updatedCallback.createDelegate(this)); 22 }, 23 failure: function(error) { 24 }, 25 objId: record.id, 26 scope: this 27 }); 28 29 return body; 30 }, 31 beforeExpand : function(record, body, rowIndex){ 32 if(this.fireEvent('beforeexpand', this, record, body, rowIndex) !== false){ 33 if (!Ext.DomQuery.selectNode('div[class=toc]', body) || !this.enableCaching) { 34 body.innerHTML = this.getBodyContent(record, rowIndex); 35 } 36 return true; 37 } else{ 38 return false; 39 } 40 } 41 });