How to change data displayed in editor

How to change data displayed in editor

reidevelopmentreidevelopment Posts: 12Questions: 4Answers: 0

I store price in the database as an integer as cents. For example, if a user enters $4.56, I store 456 in the database. I have figured out how to render that in the datatable but I can't figure out how to modify the value in the form so that when the edit form opens, it doesn't display 456, but 4.56. I have set the preInit, preEdit events and they aren't called when the edit button is pressed. On the presubmit, I do the rendering and multiply the result entered by 100 so the correct amount is stored. That works. How do I transform that in the edit form?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited December 2018

    Hi @reidevelopment ,

    The best way to go here would be use server side getter/setter formatter to get it into the format required for the Editor form (4.56) - see here.

    Then, you can change the table format with columns.render to get it looking like "$4.56" there.

    Hope that makes sense,

    Cheers,

    Colin

This discussion has been closed.