PivotGridAggregateField CellStyle

4 posts, 1 answers
  1. comgiu
    comgiu avatar
    29 posts
    Member since:
    Jun 2011

    Posted 04 Mar 2013 Link to this post

    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


  2. comgiu
    comgiu avatar
    29 posts
    Member since:
    Jun 2011

    Posted 04 Mar 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 07 Mar 2013 Link to this post

    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.
  5. comgiu
    comgiu avatar
    29 posts
    Member since:
    Jun 2011

    Posted 07 Mar 2013 Link to this post

    thanks
Back to Top