Hi,
I need a total row in my pivot grid. How can I do?
I need also a calculate column (column1-column2).
Someone can help me?
Hello Luca,
You can achieve "total row" in igPivotGrid by defining a hierarchy level. For example in the following code snippet I define hierarchy level for "ProductCategoryAlpahbetically" which makes an additional row for each letter from the alphabet:
{ caption: "ProductCategory", name: "ProductCategory", hierarchies: [{ caption: "ProductCategory", name: "ProductCategory", levels: [ { name: "AllCategories", caption: "All Categories", memberProvider: function (item) { return "All Categories"; } }, { name: "ProductCategoryAlphabetically", caption: "ProductCategoryAlphabetically", memberProvider: function (item) { return item.ProductCategory.substring(0,1); } }, { name: "ProductCategory", caption: "ProductCategory", memberProvider: function (item) { return item.ProductCategory; } }] }] }
I'm attaching a sample for your reference.
As for the "I need also a calculate column (column1-column2)." question. Each column value is a measure aggregate. I'm not sure what you're trying to achieve here, but you can create a custom aggregate like this:
measures: [ { name: "Units Sold", aggregator: function (items, cellMetadata) { var sum = 0; $.each(items, function (index, item) { sum += item.UnitsSold; }); return sum; } } ]
This aggregate just sums up the "UnitsSold" field in the data.
1680.sample.zip
Best regards, Martin Pavlov Infragistics, Inc.
Ok thank you. The Total Row works. Is it possible to automatically expand node at grid startup?