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
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
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
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
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
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
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
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?
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
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