1

当我使用 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.");
            }
        });
    },
4

1 回答 1

0

http://www.sencha.com/forum/showthread.php?151442-Nested-EXTJS-4-Grids上的Stratboogie 的回答 完成了这项工作。

我做了一些修改,将元素 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
}
于 2012-03-07T15:45:07.940 回答