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

PivotGridAggregateField CellStyle

3 Answers 60 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
comgiu
Top achievements
Rank 2
comgiu asked on 04 Mar 2013, 11:31 AM
hi,
I need to change dynamically cellStyle of a PivotGridAggregateField 
but the properties it's readonly

how can I do this ?

var rowField = new PivotGridAggregateField();
RadPivotGrid1.Fields.Add(rowField);
rowField.Aggregate = PivotGridAggregate.Sum;
rowField.DataFormatString = "{0:C}";
rowField.TotalFormatString = "{0:C}";
var style = new Style();
style.CssClass = "";
//rowField.CellStyle = style;
thanks


3 Answers, 1 is accepted

Sort by
0
comgiu
Top achievements
Rank 2
answered on 04 Mar 2013, 11:39 AM
I've modified the source this way

public virtual Style CellStyle
        {
            get
            {
                if (this.headerStyle == null)
                {
                    this.headerStyle = new Style();
 
                    if (this.IsTrackingViewState)
                    {
                        ((IStateManager)this.headerStyle).TrackViewState();
                    }
                }
                return this.headerStyle;
            }
            set
            {
                this.headerStyle = value;
            }
        }

please let me know if you can add this fox or if there's a better way to do it

thanks
0
Accepted
Antonio Stoilkov
Telerik team
answered on 07 Mar 2013, 08:20 AM
Hi,

In order to achieve your scenario you could apply the needed settings on the CellStyle property directly without the need of initializing a new instance as shown in the example below.
rowField.Aggregate = PivotGridAggregate.Sum;
rowField.DataFormatString = "{0:C}";
rowField.TotalFormatString = "{0:C}";
rowField.CellStyle.CssClass = "yourCssClass";

Kind regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
comgiu
Top achievements
Rank 2
answered on 07 Mar 2013, 08:55 AM
thanks
Tags
PivotGrid
Asked by
comgiu
Top achievements
Rank 2
Answers by
comgiu
Top achievements
Rank 2
Antonio Stoilkov
Telerik team
Share this question
or