PDA

View Full Version : Array Returns one empty and the totals and grouping still shows it



trian123
21 Jul 2008, 2:06 PM
I am trying to learn Ext and I have a problem. The array sometimes returns [] empty but the grouping and the totals still pick it up and I end up with an empty field with totals but the rest of the application runs smoothly. This is an extract of one of the pages I am using. It is very basic, I know but I am new to this and trying to figure out how I can itterate the array, do yo have any solutions?



Ext.onReady(function(){

var xg = Ext.grid;

var projdata= Data;

// shared reader
var reader = new Ext.data.ArrayReader({}, [
{name: 'projectname'},
{name: 'loan', type: 'float'},
{name: 'wpa', type: 'float'},
{name: 'projectid'},
{name: 'mu'},
{name: 'fy'},
{name: 'pl'},
{name: 'cc'},
{name: 'fy1'},
{name: 'qtr'},
{name: 'bd'},
{name: 'cst', type: 'float'},
]);

var summary = new Ext.grid.GroupSummary();
var grid = new xg.GridPanel({
store: new Ext.data.GroupingStore({
reader: reader,
data: projdata,
sortInfo:{field: 'fy', direction: "ASC"},
groupField:'mu'
}),
columns: [
{id:'mu',header: "MU", width: 8, sortable: true, dataIndex: 'mu'},
{header: "FY", width: 7, sortable: true, dataIndex: 'fy'},
{header: "PL", width: 6, sortable: true, dataIndex: 'pl'},
{header: "CC", width: 6, sortable: true, dataIndex: 'cc'},
{header: "ProjectID", width: 11, sortable: true, dataIndex: 'projectid'},
{header: "Project Name", width: 30, sortable: true, dataIndex: 'projectname'},
{header: "Loan", width: 12, sortable: true, dataIndex: 'loan',summaryType:'sum', renderer: Ext.util.Format.usMoney},
{header: "FY", width: 5, sortable: true, dataIndex: 'fy1'},
{header: "QTR", width: 5, sortable: true, dataIndex: 'qtr'},
{header: "Board Date", width: 10, sortable: true, dataIndex: 'bd'},
{header: "WPA", width: 12, sortable: true, dataIndex: 'wpa',summaryType:'sum',renderer: Ext.util.Format.usMoney},
{header: "Costs", width: 12, sortable: true, dataIndex: 'cst',summaryType:'sum', renderer: Ext.util.Format.usMoney}
],
view: new Ext.grid.GroupingView({
forceFit:true,
enableNoGroups:false, // REQUIRED!
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Projects" : "Project"]})'
}),
plugins: summary,

frame:true,
width: 780,
height: 800,
collapsible: true,
animCollapse: false,
title: 'Board Dates',
iconCls: 'icon-grid',
renderTo: wheredata
});
});