RadPivotFieldList - Hide Number Format

1 Answer 19 Views
PivotGrid
Telerik30
Top achievements
Rank 1
Iron
Telerik30 asked on 05 Nov 2021, 04:05 PM
Hello,

In RadPivotFieldList, how could we remove the NumberFormat part on the Dropdwnlist in the values part?

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Stenly
Telerik team
answered on 10 Nov 2021, 04:50 PM

Hello Zoubai,

In order to achieve the wanted behavior, you could implement a custom FieldListContextMenuBehavior, override the CreateContextMenu method to include the logic of finding and removing the menu item, and then set the new behavior to the RadPivotFieldList control. The following code snippet shows an implementation of the mentioned method, which should find and remove the Number Format item, as well as the separator on top of it:

public class MyCustomContextMenuBehavior : FieldListContextMenuBehavior
{
    protected override RadContextMenu CreateContextMenu(object dataContext)
    {
        var contextMenu = base.CreateContextMenu(dataContext);
        if (dataContext is Telerik.Pivot.Core.PropertyAggregateDescription)
        {
            var items = contextMenu.Items.Cast<RadMenuItem>().ToList();
            var itemToRemove = contextMenu.Items.Cast<RadMenuItem>().FirstOrDefault(i => (i as RadMenuItem).Header != null && (i as RadMenuItem).Header.Equals("Number Format")); ;

            if (itemToRemove != null)
            {
                //This is the separator which is over the Number Format item
                contextMenu.Items.Remove(items[9]);
                contextMenu.Items.Remove(itemToRemove);
            }
        }

        return contextMenu;
    }
} 

That said, I have implemented this approach in a sample project for you to test.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
PivotGrid
Asked by
Telerik30
Top achievements
Rank 1
Iron
Answers by
Stenly
Telerik team
Share this question
or