PDA

View Full Version : Grid summary plugin: problem with summaryType: sum



shadow_m
19 Sep 2011, 7:37 AM
Hi!
I have a problem with Grid Summary plugin.

My grid has 3 columns: 1) count 2) price 3) Sum

Sum column has a renderer:


{
xtype: 'gridcolumn',
dataIndex: 'cost',
text: 'Сума',
renderer: function(v, params, record) {
return '<span style="color:blue;"> '+ record.data.price * record.data.count + ' </span>';
}
},


I am trying to use summaryType: 'sum', but it show "0" instead of real value.
How can I fix it?
Thanks

draganica
28 Oct 2011, 3:47 AM
Najbolje da napravis custom funkciju summaryType: function(){} pa da ona uradi sumiranje

shadow_m
9 Jan 2012, 4:03 PM
Can anybody help me with this?

draganica
10 Jan 2012, 5:01 AM
try using custom summary function

summaryType: function(){....}
see in docs about params or use console.log(arguments) to find params that function uses
u can make custom summaryRenderer function also, see docs

Viorel
29 Sep 2012, 11:17 PM
fixed for me


var w = 0;
Ext.define('AM.view.grid.BudgetGrid' ,{
extend: 'Ext.grid.Panel',
alias: 'widget.budgetGrid',
id: 'budgetGrid',
store: 'StoreBudgetGrid',
title: 'Buget',

initComponent: function() {
this.columns = [
{xtype: 'rownumberer',flex: 1},
{header: 'Denumire',dataIndex:'denum',flex: 8, summaryType: 'count'},
{header: 'Subcategorie', dataIndex: 'cild', flex: 4},
{header: 'Data', dataIndex: 'data', flex: 3, renderer: Ext.util.Format.dateRenderer("d.m.Y")},
{header: 'Suma', flex: 3, dataIndex: 'suma',
summaryType: function(){
var store = Ext.getStore('StoreBudgetGrid');
var records = store.data.items;
var field = ['suma'];
function Suma(record, field) {
var total = 0;
var j = 0,
lenn = record.length;
for (; j < lenn; ++j) {
total = total + parseFloat(record[j].get(field));
}
return total.toFixed(2);
};
if (this.isGrouped()) {
var groups = this.getGroups();
var i = 0;
var len = groups.length;
var out = {},
group;
for (; i < len; i++) {
group = groups[i];
out[group.name] = Suma.apply(store, [group.children].concat(field));
}
var groupSum = out[groups[w].name];
w++;
return groupSum;
} else {
return Suma.apply(store, [records].concat(field));
}
},
summaryRenderer: function(value, summaryData, dataIndex) {
return '<b>' + value + '</b>';
}
}
],
this.features = [{
groupHeaderTpl: 'Subject: {name}',
ftype: 'groupingsummary',
hideGroupedHeader: true,
enableGroupingMenu: false
}],


this.callParent(arguments);
}
});