calx.js
calx.js copied to clipboard
Formatting issues with different thousand/decimal delimiters
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>
- Type in A0, say "2,02"
- TAB. A0 displays 2 (2.02 internally saved)
- Type in A1, say "2,03"
- shift-tab. A1 becomes 2,03%. A0 becomes "2.02"
- tab. A0 becomes 202.
- 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...
Thanks,
I am aware of this issue, and maybe I will work for the fix in near future :)