Home > Mobile >  Showing 1 decimal place in MudBlazor Table
Showing 1 decimal place in MudBlazor Table

Time:09-26

I am experimenting with a MudTable and I am trying to fix my inline editing values. I have a column(called Price at 3 decimal places in my database table) that I enter a value into and that value is then entered into a calculation which then populates another column as a decimal at 3 decimal places in the table. That column is also editable, however, the value that displays in the mudtable is more than 3 decimal places. It saves to the database as 3 decimal places but shows more in the mudtable:

for example

in database table: 3.125 in mudTable: 3.12500000

is there any way to get rid of those zeros?

my code:

<MudTd Class="pa-0" DataLabel="Month">
        <MudNumericField HideSpinButtons="true" @bind-Value="@context.Month" Required Step="0.1M" />
    </MudTd>

I am sorry if I am missing any other code, I am new, Please let me know if there is anything else to include :(

CodePudding user response:

Use the Format parameter:

<MudNumericField Format="0.########" HideSpinButtons="true" @bind-Value="@context.Month" Required Step="0.1M" />

https://mudblazor.com/api/numericfield#properties

https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings

  • Related