用extjs 4嵌套网格
问题描述:
我可以把网格放入另一个网格的插件中。用extjs 4嵌套网格
这是我的网格,我想放置在配置'插件'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')
});
这可能吗?
答
嵌套网格是可能的。下面是煎茶论坛上的解决方案:
你几乎得到了它。在插件部分,我们将创建一个空的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'.I要加载数据的家长和部分数据使用一次,部分嵌套网格他们在嵌套 也许你有任何想法。谢谢 – Hadas
在上面的代码中,没有额外的数据加载发生。我将父级的记录信息绑定到嵌套网格。 expandbody发生的唯一事情就是创建嵌套网格和渲染的实例。 –
谢谢我试试 – Hadas