Вложенная сетка с extjs 4 - PullRequest
       3

Вложенная сетка с extjs 4

3 голосов
/ 24 ноября 2011

Я могу поместить сетку в плагины другой сетки.

это моя сетка, и я хочу добавить в конфигурацию 'plugins' ext 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 Ответ

8 голосов
/ 24 ноября 2011

Вложенные сетки возможны. Вот решение с форумов 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') });
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...