Hide calculation

Hi,

i wish to hide a certain calculation column if it has no values.

Please find the attached image. I wish to hide "PnL Transfer" calculation from the left and 
"MarketMove","carry", "provisions" etc calculations from "cRev" column.


Attachment: sample_9b94cd36.zip

1 Reply

TB Thirupathi Bala Krishnan Syncfusion Team January 2, 2018 12:37 PM UTC

Hi Chaitanya, 

We have prepared a simple sample to achieve your requirement – “Need to hide the column values when the cell value is 0”. You can hide any columns based on your logic implementation in PivotGrid and it can be achieved by using SetHidden() method available in InternalGrid.  

Please find the samples and screenshots from the below location: 

Please refer the below code snippets to hide the column values: 
#MainWindow.xaml.cs 
 
        public MainWindow() 
        { 
            InitializeComponent(); 
            this.Loaded += MainWindow_Loaded; 
            this.gridControl.Loaded += GridControl_Loaded; 
        } 

        private void GridControl_Loaded(object sender, RoutedEventArgs e) 
        { 
            int row = this.gridControl.PivotEngine.RowCount - 2; 
            int column = (this.gridControl.PivotEngine.PivotRows.Count > 0) ? this.gridControl.PivotEngine.PivotRows.Count : 1; 
            for (int i = column; i < this.gridControl.PivotEngine.PivotValues[0].Count; i++) 
            { 
                if (this.gridControl.PivotEngine.PivotValues[row, i] != null && (this.gridControl.PivotEngine.PivotValues[row, i].CellType == (PivotCellType.GrandTotalCell | PivotCellType.ValueCell))) 
                { 
                    PivotCellInfo cellInfo = this.gridControl.PivotEngine.PivotValues[row, i]; 
                    if (cellInfo != null && cellInfo.FormattedText == "0.00") 
                        this.gridControl.InternalGrid.Model.ColumnWidths.SetHidden(i, i, true); 
                } 
            } 
        } 

If the above solution does not meet your actual requirement, could you please share the detailed description along with your working sample? So that it would be helpful to proceed further. 

Regards, 
Thirupathi B. 
Hi Chaitanya, 

We have prepared a simple sample to achieve your requirement – “Need to hide the column values when the cell value is 0”. You can hide any columns based on your logic implementation in PivotGrid and it can be achieved by using SetHidden() method available in InternalGrid.  

Please find the samples and screenshots from the below location: 

Please refer the below code snippets to hide the column values: 
#MainWindow.xaml.cs 
 
        public MainWindow() 
        { 
            InitializeComponent(); 
            this.Loaded += MainWindow_Loaded; 
            this.gridControl.Loaded += GridControl_Loaded; 
        } 

        private void GridControl_Loaded(object sender, RoutedEventArgs e) 
        { 
            int row = this.gridControl.PivotEngine.RowCount - 2; 
            int column = (this.gridControl.PivotEngine.PivotRows.Count > 0) ? this.gridControl.PivotEngine.PivotRows.Count : 1; 
            for (int i = column; i < this.gridControl.PivotEngine.PivotValues[0].Count; i++) 
            { 
                if (this.gridControl.PivotEngine.PivotValues[row, i] != null && (this.gridControl.PivotEngine.PivotValues[row, i].CellType == (PivotCellType.GrandTotalCell | PivotCellType.ValueCell))) 
                { 
                    PivotCellInfo cellInfo = this.gridControl.PivotEngine.PivotValues[row, i]; 
                    if (cellInfo != null && cellInfo.FormattedText == "0.00") 
                        this.gridControl.InternalGrid.Model.ColumnWidths.SetHidden(i, i, true); 
                } 
            } 
        } 
 

If the above solution does not meet your actual requirement, could you please share the detailed description along with your working sample? So that it would be helpful to proceed further. 

Regards, 
Thirupathi B. 
 


Loader.
Up arrow icon