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

RadPivotFieldList Drag&Drop Loose Custom Name

10 Answers 131 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Stefania
Top achievements
Rank 2
Stefania asked on 24 Nov 2017, 04:31 PM

Hi,

On my fields list I setting a custom display name.

When I dragged field from field list and I dropped to reportfilter/column label/ row label or values it keep the right name.

But when I drag field between reportfilter, column label, row label and values the dragged item show the Property name instead of the Display Name (see the attachment)

How can I fix it?

Thank you

10 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 29 Nov 2017, 11:07 AM
Hello Stefania,

I tried to reproduce the issue you've described in a sample project but was, unfortunately, unable to do so. I'm attaching the project I've used in the process to my reply.

Could you please have a look at it and let me know how I can modify it so that the undesired behavior is observed? Please note that I've set the DisplayName for the Date and Product properties and dragging their respective fields in the RadPivotFieldList displays the DisplayName

Thank you in advance for your cooperation on the matter.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Stefania
Top achievements
Rank 2
answered on 01 Dec 2017, 03:10 PM

Hi,

I modified your demo to reproduce the error, now the code is similar to our application.

1. Field list is generated runtime because we'll use dynamic linq

2. We can't use DisplayName on the property of the object

 

Drag Product Name from Rows section. On dragged tooltip will display Product.

I open a new ticket with your project modified
ticket ID: 1143008

Thank you

0
Dilyan Traykov
Telerik team
answered on 05 Dec 2017, 10:58 AM
Hello,

I'm also posting the recommended approach for such a scenario that I suggested in the support ticket so that it is beneficial to the community:

"To achieve the desired result you will need to create a custom RadPivotFieldList and add a handler for the DragInitialize event."

public class CustomPivotFieldList : RadPivotFieldList
{
    public CustomPivotFieldList()
    {
        DragDropManager.AddDragInitializeHandler(this, new DragInitializeEventHandler(OnDragInitialize), true);
    }
  
    private void OnDragInitialize(object sender, DragInitializeEventArgs e)
    {
        var item = e.OriginalSource as FieldBoxItem;
        if (item != null)
        {
            DescriptionWrapper context = item.DataContext as DescriptionWrapper;
  
            if (context != null)
            {
                var text = ((FieldInfoNode) ((RadPivotFieldList) sender).DataProvider.FieldInfos.RootFieldInfo.Children.First(x => x.Name == context.FieldInfo.Name)).FieldInfo.DisplayName;
                e.DragVisual = new TextBlock() { Text = text };
            }
        }
    }
}

I hope this is helpful.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Stefania
Top achievements
Rank 2
answered on 21 Dec 2017, 02:33 PM

Hi,

one more question,

keep using my previous project attached on ticket.

I'm trying to add calculated fields code behind and I should use class CalculatedPivotFieldInfo but it's inaccessible.

 

How can I do?

Thank you

0
Accepted
Dilyan Traykov
Telerik team
answered on 22 Dec 2017, 03:29 PM
Hello,

Indeed, the CalculatedPivotFieldInfo is marked as internal and is not accessible. Could you please, however, specify why you need to use this class in this scenario?

I've updated the project to include a calculated field, and have specified a custom DisplayName for it. Could you please have a look and let me know if this is what you have in mind or if there's something else I'm missing?

I look forward to your reply.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Stefania
Top achievements
Rank 2
answered on 27 Dec 2017, 08:13 AM

Hi Dilyan,

Thank you your reply. It works.

I was thinking I had to use the CalculatedPivotFieldInfo but if this is the better way to accomplish my request it's ok.

Thank you

0
Stefania
Top achievements
Rank 2
answered on 09 Feb 2018, 10:03 AM

Hi.

In the project attached when i add a field as property aggregate the code on PrepareDescriptionForField set custom name as

var description = e.Description as Telerik.Pivot.Core.PropertyAggregateDescription;
               description.CustomName = description.AggregateFunction + " of " + ((FieldInfoNode)((LocalDataSourceProvider)sender).FieldInfos.RootFieldInfo.Children.First(x => x.Name == e.FieldInfo.Name)).FieldInfo.DisplayName; //e.FieldInfo.DisplayName;

If i drag field Net, the display name is Sum of Net. But if i change the aggregate option in Average/Count, data in pivot changes correctly but field name remains Sum of Net. How can i fix it?

0
Dinko | Tech Support Engineer
Telerik team
answered on 14 Feb 2018, 09:57 AM
Hello Stefania,

This reply is to inform you that we are investigating this behavior. We will contact you again as soon as we have more information about this case.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Dinko | Tech Support Engineer
Telerik team
answered on 21 Feb 2018, 03:00 PM
Hi Stefania,

Thank you for your patience.

Let me first start with that when you set the CustomName property this is will override the internal logic of changing the current choose function. The CustomName property is suitable for scenarios when you want to change the default "Sum of" value. In your case, the CustomName property is set in the PrepareDescriptionForField event handler. This event is fired only when the user adds a description to RadPivotFieldList. In drag-drop scenario will be fired only once. If you remove the setting of the CustomName you can observe that the DisplayName property is changed correctly. 

Looking at the provided code snippet, the build logic for changing the current use function is the same as the one which you have set. If you still need to set this property you can subscribe to the SettingsChanged event of the PropertyAggregateDescription. In the event handler, you can change the CustomName property of the current PropertyAggregateDescription.
var description = e.Description as Telerik.Pivot.Core.PropertyAggregateDescription;
var aggrefateFunction = description.AggregateFunction;
var displayName = ((FieldInfoNode)((LocalDataSourceProvider)sender).FieldInfos.RootFieldInfo.Children.FirstOrDefault(x => x.Name == e.FieldInfo.Name)).FieldInfo.DisplayName;
description.CustomName = aggrefateFunction.ToString() + " of " + displayName; //e.FieldInfo.DisplayName;
description.SettingsChanged += Description_SettingsChanged;

private void Description_SettingsChanged(object sender, SettingsChangedEventArgs e)
{
    var description = sender as Telerik.Pivot.Core.PropertyAggregateDescription;
    var aggrefateFunction = description.AggregateFunction;
    string displayName = description.CustomName.Split(' ').Last();
    description.CustomName = aggrefateFunction.ToString() + " of "+ displayName;
}

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Stefania
Top achievements
Rank 2
answered on 26 Feb 2018, 10:58 AM
Thanks
Tags
PivotGrid
Asked by
Stefania
Top achievements
Rank 2
Answers by
Dilyan Traykov
Telerik team
Stefania
Top achievements
Rank 2
Dinko | Tech Support Engineer
Telerik team
Share this question
or