We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Show Column Grand Totals but hide rows grand totals

I'm using pivot grid in a very specific way and in some cases I just need to show column grand totals but hiding row grand totals. I can hide or show them both by using pivotGrid.ShowGrandTotals but I couldn't figure out how to to set them up separately. Is it possible to achieve that config?
Thanks in advance.

1 Reply

AA Arulraj A Syncfusion Team March 12, 2019 02:13 AM

Hi Carlos, 

Thanks for using Syncfusion product. 

We have analyzed the reported query “How to hide the row grand totals alone in pivot grid control”. You can achieve this requirement by invoking the RowHeights.SetHidden() method based on the grand total row index value. Also invoke the InvalidateCells method which is available in InternalGrid. If you want to hide the column grand totals alone, you can invoke the ColumnWidths.SetHidden method based on grand total column index value. You can find out the grand total row/column index value with the help of CellType property of PivotCellInfo. 
Note: ShowGrandTotals property is used to hide the both row and column grand totals in pivot grid. 

        public MainWindow() 
            this.pivotGrid1.Loaded += PivotGrid1_Loaded; 
        private void PivotGrid1_Loaded(object sender, RoutedEventArgs e) 
            //To hide the row grand totals alone. 
            int row = this.pivotGrid1.PivotEngine.RowCount - 2; 
            PivotCellInfo cellInfo = this.pivotGrid1.PivotEngine.PivotValues[row, 0]; 
            if (cellInfo != null && cellInfo.CellType == (PivotCellType.RowHeaderCell | PivotCellType.GrandTotalCell)) 
                this.pivotGrid1.InternalGrid.Model.RowHeights.SetHidden(row, row, true); 
            //To hide the column grand totals alone. 
            int col = this.pivotGrid1.PivotEngine.ColumnCount - this.pivotGrid1.PivotCalculations.Count - 1; 
            PivotCellInfo cellInfo1 = this.pivotGrid1.PivotEngine.PivotValues[0, col]; 
            if (cellInfo1 != null && cellInfo1.CellType == (PivotCellType.HeaderCell | PivotCellType.ColumnHeaderCell | PivotCellType.GrandTotalCell)) 
                for (int i = 0; i < this.pivotGrid1.PivotCalculations.Count; i++) 
                    this.pivotGrid1.InternalGrid.Model.ColumnWidths.SetHidden(col + i, col + i, true); 

Please let us know if you need any further assistance. 

Arulraj A 

Live Chat Icon For mobile
Up arrow icon