Fieldname captions

7 posts, 1 answers
  1. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 03 Dec 2012 Link to this post

    We've noticed that if we include a column in the pivotgrid, and give it a caption, that's the value that shows up in the configuration panel. All OTHER fields are picked up automatically from the data source, but the value that shows is the field name, which isn't always meaningful to the user.

    Is it possible to define captions for all fields, even those that are not initially included in the pivotgrid?
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 06 Dec 2012 Link to this post

    Hi Derek,

    To achieve the desired functionality you could try using the following approach:
    On RadPivotGrid.PreRender event you could get all fields via RadPivotGrid.Fields collection. Then you could iterate and set custom caption to each of them.
    Additionally I am sending you a simple example which demonstrates that.

    I hope this helps.

    Greetings,
    Radoslav
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 07 Nov 2013 Link to this post

    Thanks for the response.

    This works, but we've run into another issue. If we put a RadAjaxManager on the page, the field captions aren't updated when the page loads,only AFTER the control is re-loaded (ie when adding a field to the grid). If we remove the RadAjaxManager everything works as expected.

    Is there a way to get this to work on page load, while still using RadAjaxManager?
  5. Answer
    Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 13 Nov 2013 Link to this post

    Hi Derek,

    In order to resolve your issue you could try one of the following approaches:
    • Ensure that the RadAjaxManager is updating the RadPivotGrid control. The RadPivotGrid should be part of the ajaxified controls collection for the ajax initiator as shown in the example below
    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadPivotGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadPivotGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    • You could try calling RadPivotGrid Rebind method after you have set the Caption value of the PivotGridField
    void RadPivotGrid1_PreRender(object sender, EventArgs e)
    {
        for (int i = 0; i < RadPivotGrid1.Fields.Count; i++)
        {
            RadPivotGrid1.Fields[i].Caption = (i + 1).ToString();
        }
        RadPivotGrid1.Rebind();
    }

    Regards,
    Antonio Stoilkov
    Telerik
    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 the blog feed now.
  6. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 13 Nov 2013 Link to this post

    We had initially used the Ajax Manager, and the pivot was referenced correctly in the Ajax Manager, but we found that the field names weren't being updated until the pivot grid was refreshed.

    Including the rebind in the PreRender event resolved that, but note that BOTH were required to get it to work properly; the grid is referenced in the Ajax Manager, and the rebind is called at the end of the PreRender event.
  7. Bob
    Bob avatar
    6 posts
    Member since:
    May 2014

    Posted 21 May 2014 Link to this post

    Hi there,

    I have the same problem. The only difference is that it's an OLAP bound RadPivotGrid.
    Even in the PreRender the field collection is not filled yet.
    How can i reach all the fields to change their captions?

    Kind regards,

    Bob Gladon
     
  8. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 26 May 2014 Link to this post

    Hi Bob,

    You could try achieving your scenario by subscribing to RadPivotGrid FieldCreated event and changing the captions of the fields there. Note that fields are not created when hidden. You could change the captions of the fields only if they are in the RadPivotGrid Fields collection. Fields are added to the collection when dragged from the Configuration Panel or manually added to the collection in the markup or programatically in code behind.

    Regards,
    Antonio Stoilkov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017