Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 🙁

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading