2011-04-12 141 views
2

HI嵌套电网EXTJS

如何设计嵌套电网在ExtJS的 请提供一些样品(如何ExtJS的GridPanel中使用RowExpander)

+0

这是一个具体的例子:http://www.programering.com/a/MDN4cTMwATY.html – MacGyver 2014-08-07 19:23:53

回答

7

找到尝试是这样的:

//Create the Row Expander. 
var expander = new Ext.ux.grid.RowExpander({ 
    tpl : new Ext.Template('<div id="myrow-{Id}" ></div>') 
}); 

//Define the function to be called when the row is expanded. 
function expandedRow(obj, record, body, rowIndex){ 
    //absId parameter for the http request to get the absence details. 
    var absId = record.get('Id'); 

    var dynamicStore = //the new store for the nested grid. 

    //Use Id to give each grid a unique identifier. The Id is used in the row expander tpl. 
    //and in the grid.render("ID") method. 
    var row = "myrow-" + record.get("Id"); 
    var id2 = "mygrid-" + record.get("Id"); 

    //Create the nested grid.   
    var gridX = new Ext.grid.GridPanel({ 
     store: dynamicStore, 
     stripeRows: true, 
     columns: [ 
      //columns 
     ], 
     height: 120, 
     id: id2     
    });   

    //Render the grid to the row expander template(tpl). 
    gridX.render(row); 
    gridX.getEl().swallowEvent([ 'mouseover', 'mousedown', 'click', 'dblclick' ]); 
} 

//Add an expand listener to the Row Expander. 
expander.on('expand', expandedRow); 

你可以找到关于此Here

1

更多信息,这是可能做到这一点正如其他人所提到的那样,但是我建议不要这样做。

原因: 由于子网格没有被正确销毁而导致内存泄漏。 选择模型无法正常工作 事件变得混乱。

+0

你能提供更多的洞察这些内存泄漏? – 2011-10-06 13:31:19

+0

发生内存泄漏,因为网格在网格刷新时被破坏,但附加的事件处理程序等仍然存在于JS中。 – eli 2011-11-09 02:34:20