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
70
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?

Parents
  • 23953
    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.

  • 23953
    Offline posted in reply to Luca Rossi

    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.

Reply Children
No Data