Formatting number

Formatting number

teojicdteojicd Posts: 6Questions: 6Answers: 0

I am using ASP.NET / C# for server side processing. I am returning JSON to datatables with this line of code:
var jsonResult = Json(dataTableJsData, JsonRequestBehavior.AllowGet);

When I use visual studio to check the data I am returning, it is shown to be like this:

UCOST is a decimal data type with two decimal places. However, when the data is displayed on the table, there is no decimal places. Is there some sort initialization option I am missing, or do I have specifically write code to format the displayed result ?

Thanks for the help !

Answers

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    Can you show us the JSON data that the browser is loading please? Think to remember here is that in Javascript 43.00 === 43 since it doesn't have a decimal type, only a number type.

    I suspect you'll need to use the number renderer if you want to format it with two decimal places.

    Allan

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @teojicd ,

    It should just work - see here. Given your weight is also decimalised, is that displayed correctly?

    If you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.