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

radPivotFieldList FieldList Name

11 Answers 155 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 21 May 2015, 12:01 PM

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

11 Answers, 1 is accepted

Sort by
0
Ralitsa
Telerik team
answered on 22 May 2015, 12:42 PM
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
0
Tony
Top achievements
Rank 1
answered on 22 May 2015, 01:34 PM

Hi Ralitsa.

Thanks for your answer.

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

 Best regards

0
Tony
Top achievements
Rank 1
answered on 22 May 2015, 03:10 PM

Hi Ralitsa,

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

Best regards

0
Ralitsa
Telerik team
answered on 26 May 2015, 07:51 AM
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
0
Tony
Top achievements
Rank 1
answered on 26 May 2015, 11:55 AM

Hi Ralitsa.

Thanks for your answer.

I attach on the GroupDescriptorElementCreating event and it works

Best regards

0
Ralitsa
Telerik team
answered on 28 May 2015, 09:53 AM
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
0
Tony
Top achievements
Rank 1
answered on 10 Jun 2015, 04:13 PM

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

 

 

 

0
Ralitsa
Telerik team
answered on 15 Jun 2015, 07:29 AM
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
0
Tony
Top achievements
Rank 1
answered on 16 Jun 2015, 11:53 AM

Hi Ralitsa,

Thanks for your answer, it's well works.

Best regards

0
Chris
Top achievements
Rank 1
answered on 01 Oct 2020, 03:19 PM

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?

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Oct 2020, 12:19 PM
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).

Tags
PivotGrid and PivotFieldList
Asked by
Tony
Top achievements
Rank 1
Answers by
Ralitsa
Telerik team
Tony
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or