当我使用rowexpander插件展开网格行时,我正试图在网格行内创建一个网格。如何在expandbody事件上呈现子网格?
到目前为止,这是我的代码,当我定义网格面板时,它被用作事件处理程序属性:
getOtherProducts: function (rowNode, record, expandRow, eOpts) {
$.ajax({
type: 'GET',
url: "Report.aspx/GetOtherProducts",
data: { ID: record.data['ID'] },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
var subStore = Ext.create('pr.store.Store-Products');
subStore.proxy.extraParams.productID = record.data['ID'];
var subGrid = Ext.create('Ext.grid.Panel', {
store: subStore
});
subGrid.getEl().swallowEvent(['mouseover', 'mousedown', 'click', 'dblclick']);
},
error: function () {
showNotificationBar("Error retrieving product data. Re-expand the row to try again.");
}
});
},
stratboogie在http://www.sencha.com/forum/showthread.php?151442-Nested-EXTJS-4-Grids完成了任务。
我做了一个轻微的修改,将元素ID存储到阵列中
subGrids.push(subGrid.id);
然后重写分页事件处理程序以循环遍历数组,并销毁数组中具有ID的所有元素以控制内存。
function destroySubGrids(){
Ext.each(subGrids, function(id){
var subGrid = Ext.getCmp(id);
if(subGrid){
subGrid.destroy();
delete subGrid;
}
});
subGrids = [];
console.log(Ext.ComponentMgr.all.length); //debug
}