I have a field that is stored as a float, but presented as a percentage. I'm using the sample code from the docs for formatter and unformat of the cell. It all works well. However, I want to take it a logical step further. Since users see for example "55%", they should be able to enter "55" or "55%" instead of ".55". Obviously if they do that, then the cell value becomes "5500%" and stored in db as 5500.0 – which is no good.
So I would like to add a validation call back that checks if the number is >1 and if so, divides by 100. But instead of passing just the value (which is passed "by value", I need to pass the "Cell" Object. But I don't know the syntax of that. I can't hijack the "formatter" because that is called when the grid is loaded. I need a separate action for when the user edits or adds values.
I have some other situations where this would also be useful. For example, if the user types in "fred smith", I would like to store that in the db as "Fred Smith".
How useful was this discussion?
Click on a star to rate it!
Average rating / 5. Vote count:
We are sorry that this post was not useful for you!
Let us improve this post!
Thanks for your feedback!