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?
Great! Thank you.
Hello Luca,
Yes, it's possible. Checkout the following sample:
https://www.igniteui.com/pivot-grid/sorting
The API that expands a node is: expandTupleMember.
Here is the code that expands the first column and the first row in the sample:
dataSourceInitialized: function (evt, ui) { // expand the first members in the rows and in the columns in order to observe the applie sorting $("#pivotGrid").igPivotGrid("expandTupleMember", "rowAxis", 0, 0, false); $("#pivotGrid").igPivotGrid("expandTupleMember", "columnAxis", 0, 0, true); },
Best regards, Martin Pavlov Infragistics, Inc.
Ok thank you. The Total Row works. Is it possible to automatically expand node at grid startup?
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