Reputation: 41
I have a grid within a form as in the attached image. When the the customer name is changed, then the grid store is loaded with records corresponding to the customer. I want the balance textfield to be populated with the sum of Amount due column.
The image is here.
Upvotes: 4
Views: 6205
Reputation: 770
Use the store summary function:
var sum = grid.getStore().sum('NameColumn');
sencha api: sum store
Upvotes: 3
Reputation: 10374
Use like this:
store.load({
scope : this,
callback: function(records, operation, success) {
//here the store has been loaded so you can use what functions you like.
//This code sum numbers in certain column
sum = 0;
store.each(function (rec) { sum += rec.get('NameColumn'); });
}
});
Upvotes: 5