带有extjs 4的嵌套网格

时间:2011-11-24 08:35:13

标签: extjs4

我可以将网格放在另一个网格的插件中。

这是我的网格,我想放入配置'plugins'xt grid。

 var grid = new Ext.grid.GridPanel({
                    store: store,
                    columns: [
        { header: 'Customer Name', dataIndex: 'CustomerName', width: 212 },
        { header: 'Charge Date', dataIndex: 'ChargeDate', width: 212 },
        { header: 'Package Plan', dataIndex: 'PackagePlan', width: 212 },
        { header: 'Current Invoice Sum', dataIndex: 'CurrentInvoiceSum', width: 212 }
     ],
                    plugins: [{
                        ptype: 'rowexpander',
                        rowBodyTpl: ['<div style="background-color:#CBDDF3; width:643px;margin-left:147px;margin-bottom: 20px;border: 1px solid;">',
            '<p><b>Customer Details:</b><br/>{CustomerName}<br/> {CustomerAddress}, {CustomerPhone}, {CustomerEmail} </p>',
                                '<p><b>Package Type:</b> {PackagePlan}<br/>',
                                '<b>Invoice Details:</b></p>',
                   '<div class="nestedO" id="{InvoiceId}"></div> </div>',
        ]
                    }],
                    width: 900,
                    height: 450,
                    renderTo: Ext.get('Ongoing')
                });

有可能吗?

1 个答案:

答案 0 :(得分:8)

嵌套网格是可能的。以下是Sencha论坛的解决方案:

http://www.sencha.com/forum/showthread.php?151442-Nested-EXTJS-4-Grids&p=668193&viewfull=1#post668193

你几乎得到了它。在插件部分中,我们将创建一个空div,我们将在其中呈现嵌套网格:

plugins: [{
        ptype: "rowexpander",
        rowBodyTpl: ['<div id="SessionInstructionGridRow-{ClientSessionId}" ></div>']    
}],

当用户展开网格行时,我们会将嵌套网格渲染到其中。

expandbody : function(rowNode,record, expandbody) {
    var targetId = 'SessionInstructionGridRow-' + record.get('ClientSessionId');
    if (Ext.getCmp(targetId + "_grid") == null) {
        var sessionInstructionGrid = Ext.create('TS.view.client.SessionInstruction', {
            renderTo: targetId,
            id: targetId + "_grid"
        });
        rowNode.grid = sessionInstructionGrid;
        sessionInstructionGrid.getEl().swallowEvent(['mouseover', 'mousedown', 'click', 'dblclick', 'onRowFocus']);
        sessionInstructionGrid.fireEvent("bind", sessionInstructionGrid, { ClientSessionId: record.get('ClientSessionId') });
    }
}