首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ExtJS4 -渲染子网格

ExtJS4 -渲染子网格
EN

Stack Overflow用户
提问于 2012-03-07 01:38:42
回答 1查看 3.3K关注 0票数 1

当我使用rowexpander插件展开行时,我试图在网格行中创建一个网格。如何在expandbody事件上渲染子网格?

到目前为止,这是我的代码,当我定义我的网格面板时,它被用作事件处理程序属性:

代码语言:javascript
复制
 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.");
            }
        });
    },
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-07 23:45:08

stratboogie在http://www.sencha.com/forum/showthread.php?151442-Nested-EXTJS-4-Grids的回答做到了这一点。

我稍微修改了一下,将元素ID存储到一个数组中

代码语言:javascript
复制
subGrids.push(subGrid.id);

然后重写分页事件处理程序以遍历数组并销毁数组中具有ID的所有元素,以保持对内存的控制。

代码语言:javascript
复制
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
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9588969

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档