PDA

View Full Version : Grid with Grouping and Summaries only showing 1 row



craig2005
24 Feb 2011, 4:05 PM
Anyone know why this doesn't work. I only get one row and one summary. How do i tell it how to summarize and what to summarize on? I've got 30 rows and it's only showing me 1 row.

It got the example from here but i can't get it to work.

http://dev.sencha.com/deploy/dev/examples/grid/totals.html



Ext.onReady(function(){

Ext.QuickTips.init();

var xg = Ext.grid;

var reader = new Ext.data.JsonReader({
idProperty:'run_id',
fields: [
{name: 'project_id', type: 'int'},
{name: 'run_id', type: 'int'},
{name: 'project', type: 'string'},
{name: 'url', type: 'string'},
{name: 'rank', type: 'int'},
{name: 'browser', type: 'string'},
{name: 'time_to_full_load', type: 'int'},
{name: 'page_size', type: 'int'}
],
// additional configuration for remote
root:'data'
});

var summary = new Ext.ux.grid.GroupSummary();

var grid = new xg.EditorGridPanel({
ds: new Ext.data.GroupingStore({
reader: reader,
proxy : new Ext.data.HttpProxy({
url: "/reporting/apis/getData.php?runids=1,2,3",
method: 'POST'
}),
sortInfo: {field: 'browser', direction: 'ASC'},
groupField: 'project'
}),
columns: [
{
id: 'url',
header: 'url',
width: 80,
sortable: true,
dataIndex: 'url',
summaryType: 'count',
hideable: false,
summaryRenderer: function(v, params, data){
return ((v === 0 || v > 1) ? '(' + v +' Urls)' : '(1 Url)');
}
},{
header: 'project',
width: 20,
sortable: true,
dataIndex: 'project'
},{
header: 'rank',
width: 25,
sortable: true,
dataIndex: 'rank',
summaryType:'max'
},{
header: 'time_to_full_load',
width: 20,
sortable: true,
dataIndex: 'time_to_full_load',
summaryType:'average',
renderer : function(v){
return v +' seconds';
}
},{
header: 'page_size',
width: 20,
sortable: true,
dataIndex: 'page_size',
summaryType:'average'
},{
id: 'browser',
header: 'browser',
width: 20,
sortable: false,
dataIndex: 'browser',
}
],

view: new Ext.grid.GroupingView({
forceFit:true,
showGroupName: false,
enableNoGroups:false,
enableGroupingMenu:false,
hideGroupedColumn: true
}),

plugins: summary,

tbar : [{
text: 'Toggle',
tooltip: 'Toggle the visibility of summary row',
handler: function(){summary.toggleSummaries();}
}],

frame: true,
width: 800,
height: 450,
clicksToEdit: 1,
collapsible: true,
animCollapse: false,
trackMouseOver: false,
title: 'Sponsored Projects',
iconCls: 'icon-grid',
renderTo: document.body
});

// load the remote data
grid.store.load();

});

mankz
25 Feb 2011, 2:57 AM
What does your server respond?

craig2005
25 Feb 2011, 7:13 AM
{"data":[{"project_id":"3","run_id":"174","project":"Home","url":"http:\/\/www.mysite.com\/home\/index.jsp?&runid=174&pageType=Home","rank":"45","browser":"IE8","time_to_full_load":"10883","page_size":"1608019"},{"project_id":"3","run_id":"174","project":"Home","url":"http:\/\/www.mysite.com\/home\/index.jsp?&runid=174&pageType=Home","rank":"47","browser":"IE8","time_to_full_load":"12125","page_size":"1609505"},{"project_id":"3","run_id":"174","project":"Home","url":"http:\/\/www.mysite.com\/home\/index.jsp?&runid=174&pageType=Home","rank":"65","browser":"IE8","time_to_full_load":"7720","page_size":"1609503"},{"project_id":"3","run_id":"174","project":"Home","url":"http:\/\/www.mysite.com\/home\/index.jsp?&runid=174&pageType=Home","rank":"60","browser":"IE8","time_to_full_load":"8553","page_size":"1617632"},{"project_id":"3","run_id":"174","project":"Home","url":"http:\/\/www.mysite.com\/home\/index.jsp?&runid=174&pageType=Home","rank":"64","browser":"IE8","time_to_full_load":"8275","page_size":"1609504"},{"project_id":"3","run_id":"174","project":"Home","url":"http:\/\/www.mysite.com\/home\/index.jsp?&runid=174&pageType=Home","rank":"65","browser":"IE8","time_to_full_load":"9657","page_size":"1609505"},{"project_id":"3","run_id":"174","project":"Category","url":"http:\/\/www.mysite.com\/category\/index.jsp?categoryId=2484525&runid=174&pageType=Category","rank":"63","browser":"IE8","time_to_full_load":"6668","page_size":"2084422"},{"project_id":"3","run_id":"174","project":"Category","url":"http:\/\/www.mysite.com\/category\/index.jsp?categoryId=2484525&runid=174&pageType=Category","rank":"49","browser":"IE8","time_to_full_load":"10953","page_size":"2084397"},{"project_id":"3","run_id":"174","project":"Category","url":"http:\/\/www.mysite.com\/category\/index.jsp?categoryId=2484525&runid=174&pageType=Category","rank":"61","browser":"IE8","time_to_full_load":"6242","page_size":"2079552"},{"project_id":"3","run_id":"174","project":"Category","url":"http:\/\/www.mysite.com\/category\/index.jsp?categoryId=2484525&runid=174&pageType=Category","rank":"54","browser":"IE8","time_to_full_load":"11099","page_size":"2084394"},{"project_id":"3","run_id":"174","project":"Category","url":"http:\/\/www.mysite.com\/category\/index.jsp?categoryId=2484525&runid=174&pageType=Category","rank":"36","browser":"IE8","time_to_full_load":"13004","page_size":"2084396"},{"project_id":"3","run_id":"174","project":"Category","url":"http:\/\/www.mysite.com\/category\/index.jsp?categoryId=2484525&runid=174&pageType=Category","rank":"48","browser":"IE8","time_to_full_load":"9255","page_size":"1500775"},{"project_id":"3","run_id":"174","project":"Family","url":"http:\/\/www.mysite.com\/family\/index.jsp?categoryId=4191846&cp=2484525&runid=174&pageType=Family","rank":"60","browser":"IE8","time_to_full_load":"6080","page_size":"1970494"},{"project_id":"3","run_id":"174","project":"Family","url":"http:\/\/www.mysite.com\/family\/index.jsp?categoryId=4191846&cp=2484525&runid=174&pageType=Family","rank":"61","browser":"IE8","time_to_full_load":"6008","page_size":"1355384"},{"project_id":"3","run_id":"174","project":"Family","url":"http:\/\/www.mysite.com\/family\/index.jsp?categoryId=4191846&cp=2484525&runid=174&pageType=Family","rank":"53","browser":"IE8","time_to_full_load":"6969","page_size":"1965653"},{"project_id":"3","run_id":"174","project":"Family","url":"http:\/\/www.mysite.com\/family\/index.jsp?categoryId=4191846&cp=2484525&runid=174&pageType=Family","rank":"58","browser":"IE8","time_to_full_load":"6244","page_size":"1970497"},{"project_id":"3","run_id":"174","project":"Family","url":"http:\/\/www.mysite.com\/family\/index.jsp?categoryId=4191846&cp=2484525&runid=174&pageType=Family","rank":"58","browser":"IE8","time_to_full_load":"6649","page_size":"1970454"},{"project_id":"3","run_id":"174","project":"Family","url":"http:\/\/www.mysite.com\/family\/index.jsp?categoryId=4191846&cp=2484525&runid=174&pageType=Family","rank":"57","browser":"IE8","time_to_full_load":"6993","page_size":"1970496"},{"project_id":"3","run_id":"174","project":"Product","url":"http:\/\/www.mysite.com\/product\/index.jsp?productId=3628698&cp=2484525.4191846&runid=174&pageType=Product","rank":"37","browser":"IE8","time_to_full_load":"9638","page_size":"1233656"},{"project_id":"3","run_id":"174","project":"Product","url":"http:\/\/www.mysite.com\/product\/index.jsp?productId=3628698&cp=2484525.4191846&runid=174&pageType=Product","rank":"57","browser":"IE8","time_to_full_load":"6484","page_size":"1844087"},{"project_id":"3","run_id":"174","project":"Product","url":"http:\/\/www.mysite.com\/product\/index.jsp?productId=3628698&cp=2484525.4191846&runid=174&pageType=Product","rank":"40","browser":"IE8","time_to_full_load":"10901","page_size":"1233821"},{"project_id":"3","run_id":"174","project":"Product","url":"http:\/\/www.mysite.com\/product\/index.jsp?productId=3628698&cp=2484525.4191846&runid=174&pageType=Product","rank":"62","browser":"IE8","time_to_full_load":"5042","page_size":"1844088"},{"project_id":"3","run_id":"174","project":"Product","url":"http:\/\/www.mysite.com\/product\/index.jsp?productId=3628698&cp=2484525.4191846&runid=174&pageType=Product","rank":"55","browser":"IE8","time_to_full_load":"7844","page_size":"1848929"},{"project_id":"3","run_id":"174","project":"Product","url":"http:\/\/www.mysite.com\/product\/index.jsp?productId=3628698&cp=2484525.4191846&runid=174&pageType=Product","rank":"62","browser":"IE8","time_to_full_load":"6198","page_size":"1848933"},{"project_id":"3","run_id":"174","project":"Search","url":"http:\/\/www.mysite.com\/search\/index.jsp?kwCatId=&kw=baby&origkw=Baby&sr=1&runid=174&pageType=Search","rank":"61","browser":"IE8","time_to_full_load":"6677","page_size":"1548419"},{"project_id":"3","run_id":"174","project":"Search","url":"http:\/\/www.mysite.com\/search\/index.jsp?kwCatId=&kw=baby&origkw=Baby&sr=1&runid=174&pageType=Search","rank":"64","browser":"IE8","time_to_full_load":"9246","page_size":"927998"},{"project_id":"3","run_id":"174","project":"Search","url":"http:\/\/www.mysite.com\/search\/index.jsp?kwCatId=&kw=baby&origkw=Baby&sr=1&runid=174&pageType=Search","rank":"63","browser":"IE8","time_to_full_load":"6049","page_size":"1548418"},{"project_id":"3","run_id":"174","project":"Search","url":"http:\/\/www.mysite.com\/search\/index.jsp?kwCatId=&kw=baby&origkw=Baby&sr=1&runid=174&pageType=Search","rank":"65","browser":"IE8","time_to_full_load":"6146","page_size":"1548419"},{"project_id":"3","run_id":"174","project":"Search","url":"http:\/\/www.mysite.com\/search\/index.jsp?kwCatId=&kw=baby&origkw=Baby&sr=1&runid=174&pageType=Search","rank":"55","browser":"IE8","time_to_full_load":"6611","page_size":"1543413"},{"project_id":"3","run_id":"174","project":"Search","url":"http:\/\/www.mysite.com\/search\/index.jsp?kwCatId=&kw=baby&origkw=Baby&sr=1&runid=174&pageType=Search","rank":"60","browser":"IE8","time_to_full_load":"8969","page_size":"1548419"}], "total": 30}

mankz
26 Feb 2011, 3:45 AM
Your run_id is the same for all records, which seems weird to me. Your IdProperty should be something unique.

craig2005
26 Feb 2011, 7:01 AM
wow, i can't believe i missed that. Great find. Fresh eyes are always the best :-)