Completed
Last Updated: 01 Nov 2021 15:09 by ADMIN
Release R3 2021 SP1
Desislava
Created on: 21 Oct 2021 13:50
Category: PivotGrid
Type: Bug Report
0
RadPivotGrid: Aggregate functions in AggregateOptionsDialog are not localized properly

Here is my code for localizing the Sum aggregate function. The obtained result is a partial translation:

 

        public RadForm1()
        {
            PivotGridLocalizationProvider.CurrentProvider = new MyEnglishPivotGridLoclizationProvider();
            InitializeComponent();
        }

        private void RadForm1_Load(object sender, EventArgs e)
        {
            this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);

            this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Year, GroupComparer = new GroupNameComparer() });
            this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Quarter, GroupComparer = new GroupNameComparer() });
            this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Month, GroupComparer = new GroupNameComparer() });
            this.radPivotGrid1.ColumnGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "EmployeeID", GroupComparer = new GrandTotalComparer() });
            this.radPivotGrid1.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "Freight", AggregateFunction = AggregateFunctions.Sum });
            this.radPivotGrid1.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "Freight", AggregateFunction = AggregateFunctions.Count });
            this.radPivotGrid1.FilterDescriptions.Add(new PropertyFilterDescription() { PropertyName = "ShipCountry", CustomName = "Country" });
            this.radPivotGrid1.DataSource = this.ordersBindingSource;
        }

        class MyEnglishPivotGridLoclizationProvider : PivotGridLocalizationProvider
        {
            public override string GetLocalizedString(string id)
            {
                switch (id)
                {
                    case PivotStringId.Sum:
                        return "Soma"; 
                    default:
                        return base.GetLocalizedString(id);
                }
            }
        }

1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 21 Oct 2021 13:57

Currently, the possible solution is to create a custom AggregateOptionsDialog with the factory and format the displayed text for aggregate functions in the dialog:

        public RadForm1()
        {
            PivotGridLocalizationProvider.CurrentProvider = new MyEnglishPivotGridLoclizationProvider();
            InitializeComponent();
            this.radPivotGrid1.DialogsFactory = new MyDialogsFactory();
            this.radPivotFieldList1.DialogsFactory = new MyDialogsFactory();
        }

        private void RadForm1_Load(object sender, EventArgs e)
        {
            this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);

            this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Year, GroupComparer = new GroupNameComparer() });
            this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Quarter, GroupComparer = new GroupNameComparer() });
            this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Month, GroupComparer = new GroupNameComparer() });
            this.radPivotGrid1.ColumnGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "EmployeeID", GroupComparer = new GrandTotalComparer() });
            this.radPivotGrid1.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "Freight", AggregateFunction = AggregateFunctions.Sum });
            this.radPivotGrid1.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "Freight", AggregateFunction = AggregateFunctions.Count });
            this.radPivotGrid1.FilterDescriptions.Add(new PropertyFilterDescription() { PropertyName = "ShipCountry", CustomName = "Country" });
            this.radPivotGrid1.DataSource = this.ordersBindingSource;
        }

        class MyEnglishPivotGridLoclizationProvider : PivotGridLocalizationProvider
        {
            public override string GetLocalizedString(string id)
            {
                switch (id)
                {
                    case PivotStringId.Sum:
                        return "Soma"; 
                    default:
                        return base.GetLocalizedString(id);
                }
            }
        }

        class MyDialogsFactory : PivotGridDialogsFactory
        {
            public override IAggregateOptionsDialog CreateAggregateOptionsDialog()
            {
                return new MyAggregateOptionsDialog();
            }
        }
        class MyAggregateOptionsDialog : AggregateOptionsDialog
        { 
            public override void LoadSettings(Telerik.Pivot.Core.PropertyAggregateDescriptionBase aggregateDescription)
            {
                RadListControl listAggregateFunctions = this.Controls["groupBox"].Controls["listAggregateFunctions"] as RadListControl;
                var aggregatefunctions = listAggregateFunctions.DataSource; 
                listAggregateFunctions.VisualItemFormatting -= ListAggregateFunctions_VisualItemFormatting;
                listAggregateFunctions.VisualItemFormatting += ListAggregateFunctions_VisualItemFormatting;
                base.LoadSettings(aggregateDescription); 
               
            }

            private void ListAggregateFunctions_VisualItemFormatting(object sender, VisualItemFormattingEventArgs args)
            {
                AggregateFunction  obj = args.VisualItem.Data.DataBoundItem as AggregateFunction;
                if (obj!=null)
                {
                    args.VisualItem.Text = obj.DisplayName;
                }
               
            }
        }

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.