Code:
var grid = Ext.create('Ext.grid.Panel', { id: 'grid',
plugins: [{
ptype: "rowexpander",
//not sure if the name of this div id is signficant, got this from
//http://stackoverflow.com/questions/8254113/nested-grid-with-extjs-4
rowBodyTpl: ['<div id="NestedGridRow-{guid}" ></div>']
/* tried it here
listeners: {
expandbody : function(rowNode,record, expandbody) {
console.log('expandbody fired.');
var targetId = 'NestedGridRow-' + record.get('guid');
if (Ext.getCmp(targetId + "_grid") == null) {
//var sessionInstructionGrid = Ext.create('TS.view.client.SessionInstruction', { //author's grid class. Name support presumptions above.
var nestedGrid = Ext.create('Ext.grid.Panel', { //replace w/ standard Ext grid
renderTo: targetId,
id: targetId + "_grid",
columns: getColumns()
});
rowNode.grid = nestedGrid;
nestedGrid.getEl().swallowEvent(['mouseover', 'mousedown', 'click', 'dblclick', 'onRowFocus']);
nestedGrid.fireEvent("bind", nestedGrid, { guid: record.get('guid') });
}
}
}
*/
}],
/* another example I found - doesn't work...no this.view object
initComponent: function() {
this.view.on('expandbody', function (rowNode, record, expandRow) {
console.log('expandbody fired.');
var targetId = 'NestedGridRow-' + record.get('guid');
if (Ext.getCmp(targetId + "_grid") == null) {
//var sessionInstructionGrid = Ext.create('TS.view.client.SessionInstruction', { //author's grid class. Name support presumptions above.
var nestedGrid = Ext.create('Ext.grid.Panel', { //replace w/ standard Ext grid
renderTo: targetId,
id: targetId + "_grid",
columns: getColumns()
});
rowNode.grid = nestedGrid;
nestedGrid.getEl().swallowEvent(['mouseover', 'mousedown', 'click', 'dblclick', 'onRowFocus']);
nestedGrid.fireEvent("bind", nestedGrid, { guid: record.get('guid') });
}
});
},
*/
listeners: {
//perhaps the name of div id above is only significant in that it must match what is referenced
//as a target here in the expandbody handler. I'm unsure about the ClientSessionId...perhaps
//this is a FK in the clicked record.
expandbody : function(rowNode,record, expandbody) {
console.log('expandbody fired.');
var targetId = 'NestedGridRow-' + record.get('guid');
if (Ext.getCmp(targetId + "_grid") == null) {
//var sessionInstructionGrid = Ext.create('TS.view.client.SessionInstruction', { //author's grid class. Name support presumptions above.
var nestedGrid = Ext.create('Ext.grid.Panel', { //replace w/ standard Ext grid
renderTo: targetId,
id: targetId + "_grid",
columns: getColumns()
});
rowNode.grid = nestedGrid;
nestedGrid.getEl().swallowEvent(['mouseover', 'mousedown', 'click', 'dblclick', 'onRowFocus']);
nestedGrid.fireEvent("bind", nestedGrid, { guid: record.get('guid') });
}
}
},
store: store,
stateful: false,
collapsible: true,
resizable: true,
multiSelect: true,
height: 350,
width: 1000,
title: 'Summary',
renderTo: 'default_ItemCollection_Resize',
tools: [{
type: 'restore',
handler: function(event, target, owner, tool){
owner.findParentByType('gridpanel').setSize(1000,350);
}
}],
viewConfig: {
stripeRows: true,
enableTextSelection: true
},
dockedItems: [{
xtype: 'pagingtoolbar',
store: store,
dock: 'bottom',
displayInfo: true
}],
columns: getColumns()
});
});
I didn't really expect the nesting to work on this first attempt the way I half-understand everything and am hacking through this (attempting recursive addition of record being expanded), but at least need to get the event firing so that I can properly provide the object to the newly created grid.