Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
igpivotgrid Total Row and delta column
posted

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?

  • 23843
    Offline posted

    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.