ExtJS4-呈现子网格

ExtJS4-呈现子网格,extjs,grid,subgrid,Extjs,Grid,Subgrid,当我使用rowexpander插件展开网格行时,我正在尝试在网格行内创建网格。如何在expandbody事件上渲染子网格 这是到目前为止我的代码,当我定义网格面板时,它被用作事件处理程序属性: getOtherProducts: function (rowNode, record, expandRow, eOpts) { $.ajax({ type: 'GET', url: "Report.aspx/GetOtherProduct

当我使用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.");
            }
        });
    },
斯特拉特布吉的回答起了作用

我稍微修改了一下,将元素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
}

您可能需要扩展rowexpander插件。我做了一些类似的事情,但是使用了roweditor插件。