Is it possible to switch between data representations in editor form field?

Is it possible to switch between data representations in editor form field?

SurGraSurGra Posts: 4Questions: 2Answers: 0

Hi,

I am loading JSON-objects with numeric values in my editor form like this:
fields [ { label: "Amount [€]", name: "amount", data: "amount.raw"} ].

Example for a JSON-Object that is being loaded:
"amount":{"display":"250.000,00 €","raw":250000}

I would like to switch the representation/ format of the field, when a user sets focus on it.
First it has to display the value formatted like shown in the amount.display property. As soon as the field gets focus, it has to format the value and remove the seperators. After confirming the value (losing focus), the field needs to set the data representation back (for example formatting it)

I hope someone can help me out.
With best regards,

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @SurGra ,

    With this example here, one format is displayed (like your display), and one is there for editing (your raw).

    In the Editor config, keep data: 'amount.raw' for fields.data, and use amount.display for columns.data in the DataTables config (see example here).

    That should do the trick,

    Cheers,

    Colin

  • SurGraSurGra Posts: 4Questions: 2Answers: 0

    Hi @colin
    is it possible to have this behaviour in the editor form?

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Yep, see that first example I posted above.

    Colin

This discussion has been closed.