Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to format a DataSourceField/ListGridField

    Hi everyone,

    I'm using a DataSource to be displayed in a ListGrid. I use some DataSourceFloatFields to display a calculated value. I want this value to be displayed in a custumized format (eg "3,56"). By default the whole float value (eg "0.1245865787") is displayed.

    I tried to use FloatPrecisionValidator on the DataSourceFloatFields but that doesnt change anything.
    I also tried to use a CellFormatter on the ListField but when its method "format" is called, the object coming in is not the original one. It is of type Float but already rounded to something like "412.4".

    Could someone advise me and give me a working example?
    Thanks a lot for your help!
    Michael

    #2
    Using a CellFormatter is correct. Not sure how you decided the value is already rounded, but that shouldn't be the case. If you are logging it or similar to determine the value, or viewing it in a debugging, the logging system and/or the debugger may be showing you the value using a default precision, while the actual value retains full precision.

    Comment


      #3
      Yes you are right, I checked the values with logging and debugging.
      Thanks for your help!

      Comment

      Working...
      X