This is a migrated thread and some comments may be shown as answers.

Column and row label formatting/Sizing

1 Answer 187 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 06 Oct 2015, 05:03 PM

1. I am using Linq as my data source

2. I am programmatically creating the pivot data (PropertyGroupDescription)

3. I need a way to tell the differences between the ROW LABELS and the COLUMN LABELS in the GroupElementFormatting event so I can resize my ROW LABEL so I can see all the text and Right Align the test in my COLUMN LABELS.  From what I can tell, they are all the same OBJECT TYPE and I can't rely on looking at the TEXT/DESCRIPTION as this data is dynamic.

 

 TIA

 

Mark

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 08 Oct 2015, 01:41 PM
Hi Mark,

Thank you for writing.

In order to resize the row headers according to their content, you would need to iterate them and call the BestFitRowHeaders method for each of them: 
private void BestFitHeaders()
{
    for (int i = 0; i < this.radPivotGrid1.PivotGridElement.RowDescriptorsArea.Children.Count; i++)
    {
        this.radPivotGrid1.PivotGridElement.BestFitHelper.BestFitRowHeaders(i);
    }
}

Considering the RightToLeft column labels, you can still handle the GroupElementFormatting event, check for the Axis type of the Data object and if the value is Columns set the RightToLeft property to true
private void radPivotGrid1_GroupElementFormatting(object sender, PivotGroupElementEventArgs e)
{
    if (e.GroupElement.Data.Axis == PivotAxis.Columns)
    {
        e.GroupElement.RightToLeft = true;
    }
}

I am also sending you a gif file showing the result on my end.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
PivotGrid and PivotFieldList
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Hristo
Telerik team
Share this question
or