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

Change the Title Calculated fields

1 Answer 90 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
hamish
Top achievements
Rank 1
hamish asked on 08 Oct 2014, 02:58 PM
When I add custom calculated fields to the Field list it creates a folder called "Calculated Fields" in the field list. Is there anyway I can change this caption to something other than this and still retain the fact that they are calculated fields?. I only want to change the caption of the Folder in the field list from "Calculated Fields" to "Measures - calculated fields"

Thank you

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 09 Oct 2014, 10:37 AM
Hello Hamish,

You can achieve the desired by hooking to the GetDescriptionsDataAsyncCompleted event of the LocalDataSourceFieldDescriptionsProvider as shown below:

<pivot:LocalDataSourceProvider.FieldDescriptionsProvider>
    <pivot:LocalDataSourceFieldDescriptionsProvider GetDescriptionsDataAsyncCompleted="OnGetDescriptionsDataAsyncCompleted" />
</pivot:LocalDataSourceProvider.FieldDescriptionsProvider>

Afterwards in the handler you can get the current FieldTree nodes and modify them as needed. Try the following code snippet - it should achieve the desired scenario:

private void OnGetDescriptionsDataAsyncCompleted(object sender, GetDescriptionsDataCompletedEventArgs e)
{
    var rootItem = e.DescriptionsData.RootFieldInfo;
    var allContainers = rootItem.Children.ToList();
    rootItem.Children.Clear();          
 
    foreach (var item in allContainers)
    {
        if (item.Name == "Calculated Fields")
        {
            var newFolder = new ContainerNode("Measures - calculated fields", ContainerNodeRole.Folder);
 
            foreach (var child in item.Children)
            {
                newFolder.Children.Add(child);
            }
 
            rootItem.Children.Add(newFolder);
        }
        else
        {
            rootItem.Children.Add(item);
        }
    }  
}

Hope this helps.

Regards,
Kalin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
PivotGrid
Asked by
hamish
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or