Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Wolfgang Philipp on Jun 05, 2008 00:37
open dhtmlx forum
Number Format

Hello there!

I have a problem: I have a grid which shows a lot of numbers and most numbers are smaller than 1. At the moment grid does not show nulls before decimal separator for example 0.5 is shown as .5. Furthermore, i have to display 4 numbers after decimal separator.

I used the setNumberFormat("0.0000", 3) method to format the numbers. But problem now is, that grid shows a value of 0 as 0.0000 which is not wanted at all. It should not show anything in case of 0, 0.1 and not 0.1000 in case of 0.1.

Do you know how i can fix this? I guess i need to write a custom excell type or modify existing one. But where and how do I have to fix it?

I am still using Version 1.4 for this application. Thank you very much!
Answer posted by Support on Jun 05, 2008 03:48
If you not set number format - the value will be preserved as is, if you are using number format and column of edn|ron type - the number will be corrected
    mygrid.setNumberFormat("0.0",1)
    0.50 => 0.5
    00.5 => 0.5
    .5 => 0.5

>>But problem now is, that grid shows a value of 0 as 0.0000
Actually it works correctly ( maybe not as expected in your case, but correctly )
When you defining mask , the count of 0 after decimal point shows how many deciamal numbers need to be preserved.

If you need some kind of custom formatting - it can be implemented through custom excell.

http://www.dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Cell_values_formating.html#grid_art_formatcells