Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing 1 decimal place in MudBlazor Table

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 :(

like image 734
sayef4 Avatar asked Oct 24 '25 15:10

sayef4


1 Answers

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

like image 82
Dimitris Maragkos Avatar answered Oct 26 '25 04:10

Dimitris Maragkos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!