Formatting data values in cells

Hi

I have a Grid Grouping Control bound to a DataTable.  I would like the double-type values in a column to be displayed as thousands, for example 1500.15 should display as 1.5K.  Any help would be much appreciated.  Many thanks.

3 Replies

AR Arulpriya Ramalingam Syncfusion Team March 3, 2020 06:34 AM UTC

Hi Christopher, 
 
Greetings from Syncfusion. 
 
In order view the value of a column value with some arithmetic operation, the ExpressionFields can be used based on your requirement. To add the ‘K’ in the modified value, the Format property of the GridStyleInfo can be used. We have created a simple sample as per your scenario and please refer below code with example. 
 
Example code 
 
//To create the expression for the column. 
 ExpressionFieldDescriptor expression = new ExpressionFieldDescriptor("Salary", "([Source_Salary] /1000)", "System.Double"); 
 
 //Adds expression fields to the grid table. 
 this.gridGroupingControl1.TableDescriptor.ExpressionFields.Add(expression); 
 //To set the format for Expression column. 
 this.gridGroupingControl1.TableDescriptor.Columns["Salary"].Appearance.AnyRecordFieldCell.Format = "##.0 K"; 
 gridGroupingControl1.TableDescriptor.VisibleColumns.Remove("Source_Salary"); 
 
 
Please get back to us, if you have any other queries. 
 
Regards, 
Arulpriya 



CH Christopher March 4, 2020 09:22 AM UTC

Perfect!  Thank you.


AR Arulpriya Ramalingam Syncfusion Team March 5, 2020 04:56 AM UTC

Hi Christopher, 
 
Thank you for the update. Please get back to us, if you need any further assistance. 
 
Regards, 
Arulpriya 


Loader.
Up arrow icon