radPivotFieldList FieldList Name

12 posts, 0 answers
  1. Tony
    Tony avatar
    10 posts
    Member since:
    Mar 2015

    Posted 21 May 2015 Link to this post

    Hello Telerik,

    I linked a radPivotFieldList with a radPivotGrid. All of my radPivotFieldList's Controls used the CustomName expect the FieldList.

    Is there any way to use Custom Name instead of Property Name ? 

     

    I try this code too but it doesn't work
    radPivotFieldList1.FieldsControl.Nodes[0].RootNode.Text="my text0";

    Finally I try to remove a Node and adding another but it doesn't work because of the FielList is automaticaly updating after : 

                     Telerik.WinControls.UI.RadTreeNode test = new RadTreeNode(){Value =radPivotFieldList1.FieldsControl.Nodes[0].Value, Text="test" } ;

                   radPivotFieldList1.FieldsControl.Nodes.Remove(radPivotFieldList1.FieldsControl.Nodes[0]);
                   radPivotFieldList1.FieldsControl.Nodes.Add(test);

     

    Best regards

  2. Ralitsa
    Admin
    Ralitsa avatar
    192 posts

    Posted 22 May 2015 Link to this post

    Hi Tony,

    Thank you for contacting us. 

    We have already logged this issue in our Feedback Portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link -  FIX. RadPivotFieldList - does not display CustomName if field is removed and added again

    Currently I can suggest you to subscribe to the FieldsControl.NodeFormattingRowLabelsControl.VisualItemFormatting and ColumnLabelsControl.VisualItemFormatting events and change the displayed text. Here is the code snippet: 
    void ColumnLabelsControl_VisualItemFormatting(object sender, Telerik.WinControls.UI.VisualItemFormattingEventArgs args)
    {
        var data = args.VisualItem.Data.DataBoundItem as Telerik.WinControls.UI.PivotFieldList.IField;
        if (data != null && data.FieldInfo.Name == "OrderID")
        {
            ((RadItem)args.VisualItem.Children[0]).Text = "Order ID";
        }
    }
     
    void RowLabelsControl_VisualItemFormatting(object sender, Telerik.WinControls.UI.VisualItemFormattingEventArgs args)
    {
        var data = args.VisualItem.Data.DataBoundItem as Telerik.WinControls.UI.PivotFieldList.ILabel;
        if (data != null && data.FieldInfo.Name == "OrderID")
        {
            ((RadItem)args.VisualItem.Children[0]).Text = "Order ID";
        }
    }
     
    void  FieldsControl_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e)
    {
        if (e.Node.Text == "OrderID")
        {
            e.NodeElement.ContentElement.Text = "Order ID";
        }
    }

    In the attachment you can find a sample demo and video which demonstrates the approach. 

    I hope this will help. Do not hesitate to write back with further questions. 

    Regards,
    Ralitsa
    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
  3. Tony
    Tony avatar
    10 posts
    Member since:
    Mar 2015

    Posted 22 May 2015 in reply to Ralitsa Link to this post

    Hi Ralitsa.

    Thanks for your answer.

    It well works, i hope it could be automatised soon.

     Best regards

  4. Tony
    Tony avatar
    10 posts
    Member since:
    Mar 2015

    Posted 22 May 2015 in reply to Tony Link to this post

    Hi Ralitsa,

     I've got the same problem with the radpivotgrid Associated. can you tell me events to suscribe ?

    Best regards

  5. Ralitsa
    Admin
    Ralitsa avatar
    192 posts

    Posted 26 May 2015 Link to this post

    Hi Tony,

    Thank you for your reply. 

    You can subscribe to the DataProvider.PrepareDescriptionForField event and set the CustomName property. Here is the code snippet: 
    private void DataProvider_PrepareDescriptionForField(object sender, PrepareDescriptionForFieldEventArgs e)
    {
        if (e.Description.DisplayName == "ShipCity")
        {
            e.Description = new PropertyGroupDescription() { PropertyName = e.Description.DisplayName, GroupComparer = new GrandTotalComparer(), CustomName = "Ship City" };
        }
    }

    In the attachments you can find the modified project. 

    I hope this will help you. Let me know if you have any other questions.

    Regards,
    Ralitsa
    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
  6. Tony
    Tony avatar
    10 posts
    Member since:
    Mar 2015

    Posted 26 May 2015 in reply to Ralitsa Link to this post

    Hi Ralitsa.

    Thanks for your answer.

    I attach on the GroupDescriptorElementCreating event and it works

    Best regards

  7. Ralitsa
    Admin
    Ralitsa avatar
    192 posts

    Posted 28 May 2015 Link to this post

    Hi Tony,

    I am glad to hear that everything works fine for you now. Do not hesitate to write back if you have additional questions.

    Regards,
    Ralitsa
    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
  8. Tony
    Tony avatar
    10 posts
    Member since:
    Mar 2015

    Posted 10 Jun 2015 in reply to Ralitsa Link to this post

    Hi,

     I've got a new question. How do you change the stringformat of an aggregateDescriptor created by user ? In fact, when users use the radpivotfield to define an aggregate descriptor, I attach myself to the AggregateDescriptorElementCreating event. But i don't find how to access to the stringFormat.

    I hope someone got the solution.

     Best regards

     

     

     

  9. Ralitsa
    Admin
    Ralitsa avatar
    192 posts

    Posted 15 Jun 2015 Link to this post

    Hi Tony,

    Thank you for contacting us. 

    You can refer to the following code snippet demonstrating how to change StringFormat property of the AggregateDescriptor in the handler of the AggregateDescriptorElementCreating event:
    void radPivotGrid1_AggregateDescriptorElementCreating(object sender, Telerik.WinControls.UI.AggregateDescriptorElementCreatingEventArgs e)
    {
        PropertyAggregateDescription agg = (PropertyAggregateDescription)e.AggregateDescriptorElement.AggregateDescriptor;
        if (agg.PropertyName == "OrderID")
        {
            agg.StringFormat = "C2";
        }
    }

    I hope this will help. Do not hesitate to write back with further questions.

    Regards,
    Ralitsa
    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
  10. Tony
    Tony avatar
    10 posts
    Member since:
    Mar 2015

    Posted 16 Jun 2015 in reply to Ralitsa Link to this post

    Hi Ralitsa,

    Thanks for your answer, it's well works.

    Best regards

  11. Chris
    Chris avatar
    1 posts
    Member since:
    Jun 2015

    Posted 01 Oct 2020 Link to this post

    Ralitsa, your solution worked for providing a custom name in the Field List, but after doing that, my fields are not sorted ascending anymore.

    Here is a code snippet:

    this.provider = new LocalDataSourceProvider() { ItemsSource = gridData };

    this.radPivotFieldList1.FieldsControl.SortOrder = System.Windows.Forms.SortOrder.Ascending;

    Somewhere after this the events get fired and change the field names so that the sorting is ruined. Where do I re-sort?

  12. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4172 posts

    Posted 02 Oct 2020 Link to this post

    Hello, Chris,
     
    The FieldsControl inside RadPivotFieldList is actually represented by a RadTreeView. It can sort its nodes via the mentioned SortOrder property: https://docs.telerik.com/devtools/winforms/controls/treeview/working-with-nodes/sorting-nodes 

    However, please have in mind that the nodes are sorted by the RadTreeNode.Text property, not the visual element property, e.g. not the NodeElement.ContentElement.Text in the NodeFormatting event.

    However, RadTreeView supports custom sorting. Thus, you can control how the nodes are being ordered by specifying the RadPivotFieldList.FieldsControl.TreeViewElement.Comparer. A sample approach is demonstrated here: https://docs.telerik.com/devtools/winforms/controls/treeview/working-with-nodes/custom-sorting 

    I can suggest you to store into an appropriate data structure (e.g. a Dictionary<key,value>) the node's text and a sort order number. Thus, in the TreeNodeComparer you can extract the order index by the node's text and thus specify the sort result.

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Back to Top