calx.js icon indicating copy to clipboard operation
calx.js copied to clipboard

Formatting issues with different thousand/decimal delimiters

Open wkrueger opened this issue 9 years ago • 1 comments

In pt-br locale, thousand delimiter is ., while decimal delimiter is ,.

Case:

<form id="calx_form">
    <input type="tel" data-cell="A0" data-format="0">
    <input type="tel" data-cell="A1" data-format="0.00%">
</form>
  1. Type in A0, say "2,02"
  2. TAB. A0 displays 2 (2.02 internally saved)
  3. Type in A1, say "2,03"
  4. shift-tab. A1 becomes 2,03%. A0 becomes "2.02"
  5. tab. A0 becomes 202.
  6. shift-tab. A1 becomes 203%.

Workaround:

    this.el.on('calx.getValue', 'input[data-cell]', function(){
        var cellAddr    = $(this).attr('data-cell'),
            currentCell = currentSheet.cells[cellAddr],
            cellValue   = currentCell.getValue(),
            cellFormat  = currentCell.getFormat();

        //removed % case here        

        if(!currentCell.isCheckbox){
            //from currentCell.el.val( cellValue );
            currentCell.el.val( numeral(cellValue).format(cellFormat) );
        }

    });

Remove "%" handling case. Apply formatted value to cell. This is not 100% correct because now the user never sees the real value of the cell when selected, but it was ok for my use case. A workaround...

wkrueger avatar Sep 21 '15 15:09 wkrueger

Thanks,

I am aware of this issue, and maybe I will work for the fix in near future :)

ikhsan017 avatar Nov 12 '15 04:11 ikhsan017