Change the Title Calculated fields

2 posts, 0 answers
  1. hamish
    hamish avatar
    44 posts
    Member since:
    Jun 2007

    Posted 08 Oct 2014 Link to this post

    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
  2. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 09 Oct 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top