Decimal formatting Editor

Decimal formatting Editor

taisto_onnelataisto_onnela Posts: 1Questions: 1Answers: 0

Hi, I am formatting the decimal char in the tables when loading data from api like:
"ajax": {
"url": "http://localhost:9123/api/numerics",
"dataSrc": function (json) {....

But How do I format the return from server when using Editor ?

I get something like this:

12,34
23.45 (edited)
34,56
45,67

/taisto

This question has accepted answers - jump to:

Answers

  • fabioberettafabioberetta Posts: 74Questions: 23Answers: 4
    Answer ✓

    You can probably render the field in the editor definition using render.

    Example here.
    https://datatables.net/examples/advanced_init/column_render.html

    In any case if you need the function to round figures (like to round money amounts) I would recommend to do it at the source.

    In my case I have a database stored procedure to return amount of payment. Any rounding is done by the SQL stored procedure and the editor just displays it.

    ty
    f

  • allanallan Posts: 61,453Questions: 1Answers: 10,055 Site admin
    Answer ✓

    Ideally the server would actually do the editing so the client-side just sees the formatted number. That is the approach that the provided PHP, .NET and Node libraries use.

    However, I'm guessing you aren't using them? You would need to use postSubmit to spin through the updated or created records and modify the numbers as needed.

    Regards,
    Allan

This discussion has been closed.