We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Customise the NumberFormatInfo used in a GridSummaryColumn

Hello,

Is there a way to cutomize the NumberFormatInfo(NumberDecimalSeparator, NumberGroupSeparator, NumberDecimalDigits, NumberGroupSizes) used in a GridSummaryColumn Format property ? by default, it is using the CultureInfo of the application.
What i'm trying to do is allow the user to change NumberFormatInfo of the displayed GridSummaryColumn in a GridTableSummaryRow.

Many thanks,
Anas

3 Replies

JS Jayapradha S Syncfusion Team June 19, 2015 02:50 AM UTC

Hi Anas,

Thank you for using Syncfusion products.


We have analyzed your requirement and you can use NumberFormatInfo properties to apply the format for Summary columns by overriding the GridTableSummaryCellRenderer as shown in the below code snippet,


Code Snippet:

  public override void OnUpdateEditBinding(Syncfusion.UI.Xaml.ScrollAxis.RowColumnIndex cellRowcolumnIndex, Syncfusion.UI.Xaml.Grid.GridTableSummaryCell element, Syncfusion.UI.Xaml.Grid.GridColumn column, object dataContext)

        {

            base.OnUpdateEditBinding(cellRowcolumnIndex, element, column, dataContext);

            var record = dataContext as SummaryRecordEntry;

            if (dataContext is SummaryRecordEntry)

            {

                foreach (ISummaryColumn summaryColumn in record.SummaryRow.SummaryColumns)

                {

                    if (summaryColumn.MappingName.Contains(column.MappingName))

                    {


                        if (record.SummaryRow.ShowSummaryInRow)

                            element.Content = SummaryCreator.GetSummaryDisplayTextForRow(record, this.DataGrid.View);


                        else

                            element.Content = SummaryCreator.GetSummaryDisplayText(record, column.MappingName, this.DataGrid.View);


                        NumberFormatInfo format = new NumberFormatInfo();

                        format.NumberDecimalDigits = 3;

                        format.NumberDecimalSeparator = ",";

                        format.NumberGroupSeparator = "*";

                        if (element.Content != string.Empty)

                            element.Content = Convert.ToDouble(element.Content).ToString("C", format);


                    }

                }
            }



We have prepared  a sample for your requirement and please find the sample from the below location,

Sample Link: 
CustomNumberFormat_Summary


Kindly let us know if you require any further assistance on this.

Regards,

Jayapradha


AE Anas El Hallabi June 19, 2015 11:45 AM UTC

Hello Jayapradha,
Thank your for your answer. I was able to modify the NumberFormatInfo properties for summary columns.

Anas


JS Jayapradha S Syncfusion Team June 22, 2015 04:08 AM UTC

Hi Anas,

Thank you for your update.

Please let us know if you have any other queries.

Regards,
Jayapradha


Loader.
Live Chat Icon For mobile
Up arrow icon