Razgriz
Razgriz

Reputation: 7343

Getting the value of the summary row in the grid

I am building a web application and I have a grid with rows that the user can fill up.

I am summing up a column using the Summary Feature of the Grid and so far, it works. However, what I want to do is to be able to get that sum in the summary feature because I will use it in some function calls.

I've read the docs for the Summary Feature but it does not seem that there's a straightforward way of getting the sum in the summary feature.

Upvotes: 0

Views: 2814

Answers (2)

Luca Migliori
Luca Migliori

Reputation: 119

On event or on your request

var SUM = GridStore.sum('col1');

Upvotes: 1

jaredboone
jaredboone

Reputation: 71

Because the store data may be loaded asynchronously, you will need to make use of an event handler which is fired after the store is loaded. You might try intercepting the sum by implementing the summaryRenderer in your grid's column model.

columns: [
    {
        dataIndex: 'col1',
        text: 'Column1',
        summaryType: 'sum'
        summaryRenderer: function(value, summaryData, field) {
            // TODO: assign value to an in-scope variable
            // or pass value to another function
            console.log(value.toString());
            return value;
        }
    },
], 

Upvotes: 1

Related Questions