Code:
top5FundsStore = new Ext.data.GroupingStore({
id: 'id',
hidden: true,
reader: new Ext.data.JsonReader({
root: 'top5Fundsrows',
totalProperty: 'top5FundsTotalRows',
fields: ['recId', 'a','b','c']
}),
sortInfo:{field: 'b', direction: "DESC"}
});
expander = new Ext.ux.grid.RowExpander({});
top5FundsGrid = new Ext.grid.GridPanel({
store: top5FundsStore,
title: 'Top 5 Fund Holdings',
autoScroll: true,
flex: 4,
cm: new Ext.grid.ColumnModel([expander, {
header: "Fund Name",
dataIndex: 'a'
},{
id: 'b',
header: "AUM (USD)(mn)",
dataIndex: 'b',
renderer: numberValueRenderer
},{
id: 'c',
header: "Portfolio Manager",
dataIndex: 'c',
renderer: tTipRenderer
}]),
view: new Ext.grid.GridView({
forceFit: true
}),
tools: [{
id: 'excel',
qtip: 'Export to Excel',
handler: function(event, toolEl, panel){
window.location = '/dbPortal/exce /generateExcel?excelForPage=ClientPresentation&excelForGrid=top5Funds';
}
}],
tbar: [{
text: 'Expand all',
handler: function() {
for(var x=0;x<top5FundsStore.getTotalCount();x++){
expander.expandRow(x);
}
}
},
' ',
{
text: 'Collapse all',
handler: function() {
for(var x=0;x<top5FundsStore.getTotalCount();x++){
expander.collapseRow(x);
}
}
}],
layout: 'anchor',
anchor: '98%',
autoHeight: true,
plugins: expander,
collapsible: true
});
var records = ' ';
top5FundsGrid.on('click', function(e){
top5FundsGrid.suspendEvents();
});
top5FundsGrid.on('sortchange', function(grid, sortInfo){
records = ' ';
});
onExpand = function(expander, record, body, index){
var recId = record.get("recId");
if(records.indexOf(recId + "fundHolding") == -1){
fundHoldingsStore = new Rdr.data.DwrGroupingStore({
dwrFunction : DwrClientPresentationNew.loadFundHoldings,
id: 'id',
reader: new Ext.data.JsonReader({
totalProperty: 'total',
root: 'rows',
fields: ['a', 'b', 'c', 'd', 'e', 'f', 'g','stkName']
})
});
fundHoldingsStore.setBaseParam('recId',recId) ;
fundHoldingsStore.load();
fundHoldingsStore.on('load', function(store, array, options){
if(fundHoldingsStore.getTotalCount() > 0){
fundHoldingsGrid = new Ext.grid.GridPanel({
store: fundHoldingsStore,
cm: commonColModel,
stripeRows: false,
border: true,
view: new Ext.grid.GridView({
forceFit: true
}),
layout:'anchor',
autoHeight: true,
anchor: '98%',
renderTo: body,
border: true,
titleCollapse: false,
collapsible: false
});
records += recId + "fundHolding" + ";";
}
});
}
}
expander.on('expand', onExpand);