Autosizing Row Header is wrong if only PivotCalculations exist

Lets assume a list of data with: Year, Company_name, num_Companies, num_Employes, num_Beds, num_Patients
Now I want to have the Years in the columns and each of the num_... per row showing the sum (for all records)
Therefore set:
pivotGrid.ShowCalculationsAsColumns = false;

And define the columns and rows ...
pivotGrid.PivotColumns.Add(new PivotItem { FieldMappingName = "Year", TotalHeader = "Total" });
pivotGrid.PivotCalculations.Add(new PivotComputationInfo { FieldName = "num_Companies",  FieldCaption = "Anzahl Betriebe", SummaryType = SummaryType.Sum });
pivotGrid.PivotCalculations.Add(new PivotComputationInfo { FieldName = "num_Employees", FieldCaption = "Beschäftigte am 31.12", SummaryType = SummaryType.Sum });
pivotGrid.PivotCalculations.Add(new PivotComputationInfo { FieldName = "num_Beds", FieldCaption = "Betten am 1.1", SummaryType = SummaryType.Sum });
pivotGrid.PivotCalculations.Add(new PivotComputationInfo { FieldName = "num_Patients", FieldCaption = "Leistungsempfänger am 31.12", SummaryType = SummaryType.Sum });

Then the 1. column containing the row captions is auto sized, but way to wide. See Attached file:
How can I controll the with of this column ?


Attachment: Pivotdemo_c020484e.7z

1 Reply

TB Thirupathi Bala Krishnan Syncfusion Team September 21, 2018 11:29 AM UTC

Hi Andreas, 
 
Thank you for contacting Syncfusion Support. 
 
We have checked your requirement – “To resize the column width values for pivot grid control.” You can achieve this requirement by setting your own values into the “ColWidths” property of TableModel. 
 
Please refer the below code sample: 
 
#Form1.cs 
 
        public Form1() 
        { 
            InitializeComponent(); 
            InitializeGrid(); 
            this.pivotGridControl1.TableModel.ColWidths[1] = 120; 
            this.pivotGridControl1.TableControl.GroupDropArea.ColWidthsChanged += GroupDropArea_ColWidthsChanged; 
        } 
 
private void GroupDropArea_ColWidthsChanged(object sender,  GridRowColSizeChangedEventArgs e) 
        { 
            this.pivotGridControl1.TableModel.ColWidths[1] = 120; 
        } 
 
 
Please find our working sample from the following location: 
 
Also, please refer our UG documentation from the below link: 
 
Regards, 
Thirupathi B. 
 


Loader.
Up arrow icon