2012-03-06 74 views
1

我想在使用rowexpander插件展开该行时在网格行内创建网格。如何在expandbody事件上渲染子网格?ExtJS4 - 呈现子网格

这是到目前为止我的代码,它被用来作为一个事件处理财产时,我定义我的网格面板:

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

您使用的是哪个版本? – Eric 2012-03-06 18:23:01

+0

您可能需要扩展rowexpander插件。我做了类似的事情,但使用roweditor插件,[像这样](http://stackoverflow.com/questions/8812147/extjs-extend-grid-roweditor-plugin-to-edit-array)。 – Geronimo 2012-03-06 19:02:49

回答

0

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 
} 
+0

我找到了一个链接http://jsfiddle.net/slimjack/XFGBM/,它解释了嵌套的网格 – aswininayak 2013-08-22 07:19:40