I have one of my column as amount, i need that to be custom formatted. The format should look like "#,###0.00" Tried this below code, but in the UI i see #,###0.00 in place of numbers.
protected string Format(ControlDataField field, object value) { return "#,###0.00"; } protected override void OnInit(EventArgs e) { ExposureDetailsGrid.Load += (grid, arg) => { ((WebDataGrid)grid).Columns[5].FormatFieldMethod = (field, value) => { return PRISMConstants.AmountFormat; }; }; }
Please help me!!
This is the code i tried
protected override void OnInit(EventArgs e) { ExposureDetailsGrid.Load += (grid, arg) => { ((WebDataGrid)grid).Columns[ExposureDetailsGrid.Columns.IndexOf(ExposureDetailsGrid.Columns.FromKey("EXPO_AUTH_AMT"))].FormatFieldMethod = (field, value) => { return "#,###0.00"; }; }; }
Hello,
Thank you for the update. With the FormatFieldMethod you have to actually format the value yourself then return it. Whatever value you return will be the value that displays:
http://ko.infragistics.com/community/forums/t/19758.aspx
If you want to apply a format string without formatting yourself I recommend use the DataFormatString property of the column. You can set it something like this:
<ig:BoundDataField Key="Department" DataFieldName="Department" DataFormatString="{0:N2}"> <Header Text="Department" /> </ig:BoundDataField>
That will format the column to be a number with comma separators for the thousands place and two decimal points. You can see the following link for other formats you can apply:
https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx
I am also attaching a sample (note I have removed the ig_res folder). Please let me know if you have any further questions concerning this matter.