Grid Column format for decimal value type

Hello,

I am trying to implement following functionality but I can't get format to work..
Here is what I have:

[Column(TypeName = "decimal(18,4)")]
public decimal ArrivalFee { get; set; }

When I try to load it on a grid I get value formatted to 0.0000 which is fine

RadzenGridColumn TItem="ContractorRate" Property="ArrivalFee" Title="Arrival Fee" FormatString="0.00" Type="decimal" Width="140px"
EditTemplate Context="ArrivalCost"
RadzenNumeric Min="0" @bind-Value="@ArrivalCost.ArrivalFee" /
/EditTemplate
/RadzenGridColumn
however I would like to show it on a grid as 0.00 but store value as 0.0000

I tried following and none of them worked:

FormatString="0.00" Type="decimal"
FormatString="{0.00}" Type="decimal"
FormatString="0.00" Type="string"
FormatString="{0.00}" Type="string"

Format="0.00" Type="decimal"
Format="{0.00}" Type="decimal"
Format="0.00" Type="string"
Format="{0.00}" Type="string"

Does anyone know how or if this is even possible?

Hi @bomner,

Radzen passes the FormatString property of the column directly to String.Format and renders its output:

@(String.Format(column.FormatString, PropertyAccess.GetValue(item, column.Property)));

I suggest you double-check your format string.

In case anyone else lands here like I did, here are a couple examples for FormatString:

  • Show 1.2345 as 1.23
    "{0:N2}"
  • Show 2.340 as $2.34
    "{0:C2}"
3 Likes

This kind of sample needs to be put into the documentation.

1 Like

For anyone else that comes across this thread, here is a example of how this would be implemented as a RadzenDataGridColumn:

<RadzenDataGridColumn TItem="TblTransaction" Property="SubTotal" Title="SubTotal" FormatString="{0:C2}" Width="50px" />

Outputs: $250.25

4 Likes