Format German numbers in inline editing

Format German numbers in inline editing

sven_oliver_simpsonsven_oliver_simpson Posts: 3Questions: 2Answers: 0

Hi,

using $.fn.dataTable.render.number( '.', ',', 2, '€' ) the numbers are shown in German Format like €1.234,56.
By clicking on the number for inline editing it changes to the 1234.56
How can I change it to 1234,56 and process it correctly when sending to the server?

Regards

SOS

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    edited March 2015

    Hi Sven,

    Editor is showing the data as it is given by the server to the browser. The columns.render function will manipulate that data into the display you see in the table, but Editor uses the "raw" data.

    So the best thing to do is probably to have the server perform the formatting and deformatting for you - you can do this with the getFormatter and setFormatter methods in the PHP libraries for Editor (assuming you are using the PHP libraries) - documentation here. You would use the getFormatter to replace the . with , and the setFormatter for vice versa.

    Regards,
    Allan

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    As a follow up, I was just thinking that the best solution possible would be to use a number with English formatting as normal, but to use <input type="number"> and the browser would do the localisation for you.

    You might be interested in this article on that topic.

    You could try this approach in Editor using the following for your field:

    {
      name: '...',
      attr: {
        type: 'number',
        lang: 'de'
      }
    }
    

    Allan

This discussion has been closed.