当我使用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.");
}
});
},
答案 0 :(得分:0)
我做了一些修改,将Element 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
}