RadPivotFieldList Drag&Drop Loose Custom Name

11 posts, 1 answers
  1. Stefania
    Stefania avatar
    150 posts
    Member since:
    May 2013

    Posted 24 Nov 2017 Link to this post

    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

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    723 posts

    Posted 29 Nov 2017 Link to this post

    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.
  3. Stefania
    Stefania avatar
    150 posts
    Member since:
    May 2013

    Posted 01 Dec 2017 Link to this post

    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

  4. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    723 posts

    Posted 05 Dec 2017 Link to this post

    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.
  5. Stefania
    Stefania avatar
    150 posts
    Member since:
    May 2013

    Posted 21 Dec 2017 Link to this post

    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

  6. Answer
    Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    723 posts

    Posted 22 Dec 2017 Link to this post

    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.
  7. Stefania
    Stefania avatar
    150 posts
    Member since:
    May 2013

    Posted 27 Dec 2017 in reply to Dilyan Traykov Link to this post

    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

  8. Stefania
    Stefania avatar
    150 posts
    Member since:
    May 2013

    Posted 09 Feb Link to this post

    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?

  9. Dinko
    Admin
    Dinko avatar
    576 posts

    Posted 14 Feb Link to this post

    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.
  10. Dinko
    Admin
    Dinko avatar
    576 posts

    Posted 21 Feb Link to this post

    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.
  11. Stefania
    Stefania avatar
    150 posts
    Member since:
    May 2013

    Posted 26 Feb in reply to Dinko Link to this post

    Thanks
Back to Top