嵌套网格(extjs 4)

3

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

这是我的网格,我想将其放入配置“plugins”的ext网格中。

 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个回答

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') });
    }
}

我告诉你我的问题: 我想在创建父网格时创建嵌套网格,而不是在“expandbody”时创建。我想一次加载数据,并将数据的一部分用于父级,另一部分用于嵌套。 也许你有什么想法。谢谢。 - Hadas
在上述代码中,没有发生额外的数据加载。我将父记录信息绑定到嵌套网格中。在expandbody中唯一发生的事情就是创建嵌套网格实例并进行渲染。 - Abdel Raoof Olakara
这只是我的视图名称(嵌套网格的名称)...请给出适当的嵌套网格名称,以便ExtJS可以实例化它。 - Abdel Raoof Olakara
我可以用什么代替这个 'Ext.gridPanel' 吗? - Hadas
也许你可以给我投票,这样我们就可以在聊天中讨论。 如果我使用 'Ext.gridPanel',它会说它不是构造函数。 - Hadas
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接