Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by M.Steinboeck on Jan 02, 2008 03:57
open dhtmlx forum
dhtmlxgrid custom decimal and date formats

I could not find settings for german decimal points, and e.g. iso-date-formatting in the grid. How could i set input (and display-)format of numbers to , as decimal point, and dot as thousands-mark?
Answer posted by Support on Jan 14, 2008 08:45
The setNumberFormat allow to set custom chars as group|decimal separators, for example

    grid.setNumberFormat("0,000.00",1,".",",");

will set mask where comma used as decimal point, and point used as a group separator.
Answer posted by M.Steinböck on Jan 14, 2008 11:04
yes, BUT i think you mixed it up, thrd param. is the decimal separator, and the last one the thousands group char, and - this is more important, i still have to use DOT to input a decimal separator, which is not common in german-speaking countries ...
Any (more) solutions?
Answer posted by Support on Jan 15, 2008 02:01
Yes, I placed parameters in incorrect order. The correct is

    grid.setNumberFormat("0,000.00",1,",",".");

In such case grid will show data in necessary format, but it will use original data format as inner cell value.
Please check attached sample.
Attachments (1)
Answer posted by M.Steinböck on Jan 17, 2008 00:17
Thanks, but it still has the same problem - the common german decimal separator is "," (comma) not . (dot) so - during edit-mode a number has to be displayed like "1234567,89" (with or without thousands-separator) and (only) "," has to be accepted as decimal separator.
I found something like "build your own editor" in your documentation - maybe this could be a solution?
Regards, M.S.
Answer posted by Support on Jan 17, 2008 03:44
Any type of data transformation can be achieved by custom excells, but as more simple way, if you need the "," for all edn cells you can just update code in next way ( it need to be used with previously mentioned formatting command )


dhtmlxgridcell.js

function eXcell_ed(cell){
    ...
    this.edit = function(){
                    this.cell.atag=((!this.grid.multiLine)&&(_isKHTML||_isMacOS||_isFF))?"INPUT":"TEXTAREA";
                    this.val = this.getValue();
                    this.val=this.val.toString().replace(".",","); // << this line added

function eXcell_edn(cell){
    ...
    this.detach = function(){
                    var tv=this.obj.value;
                     tv=tv.toString().replace(",","."); //<< this line added
                   
Answer posted by M.steinböck on Jan 17, 2008 07:35
THX, Problem solved .
Answer posted by Hans on May 18, 2008 14:06

Hi! I tried this solution and it seemed to work fine. But, then all dots(.) in all ed cells are replaced with commas(,).
For example http://www.google.com becomes "www,google,com" when entering a cell.

How can we make sure that this modification only affects numeric cells?

Thanks!

Answer posted by Support on May 19, 2008 06:22

>>Hi! I tried this solution and it seemed to work fine.
The solution with setNumberFormat is a better way to format cell values ( it not requires code modification )

>>How can we make sure that this modification only affects numeric cells?
The modification affects any cells of "edn" type.
You can use edn type for numeric columns and ed type for text ones
Basically it possible to extend logic, so code will check is it number, before replacing commas - I can provide details if you interested - but usage of separate column types seems as better solution.