jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Comma decimal separator
Tagged: grid, jqxnumberinput
This topic contains 4 replies, has 2 voices, and was last updated by Peter Stoev 12 years, 4 months ago.
-
AuthorComma decimal separator Posts
-
Hi,
just upgraded to 2.5.5, but issues with comma decimal separator persist. Now comma is visible in numberinput editor, but when editor is closed, cells value is 0, likely because of the following code:
case "numberinput": if (this.editcell.editor.jqxNumberInput) { var c = this.editcell.editor.jqxNumberInput("getDecimal"); f = new Number(c); f = parseFloat(f); if (isNaN(f)) { f = 0; } if (d.displayfield != d.datafield) { f = { label: f, value: f }; } } break; }
c comes in as comma separated decimal (12,67) and Number fails to convert it to number.
Do you have any workaround?
Br. Alex
Hi alexz,
Please, send us a sample which reproduces the reported behavior. We would be glad to test it.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThe column declaration:
{text: 'Korkeus', datafield: 'Height',cellsrenderer: function (row, column, value, defaultHtml, columnProperties) { return decimalDisplayColumnRenderer (row, column, value, defaultHtml, columnProperties); }, columntype: 'numberinput',createeditor: function (row, value, editor) { editor.jqxNumberInput({ decimalSeparator: ',', groupSeparator: ' ' }); }}
The renderer function (not important, createeditor seems to be the main cause)
var decimalDisplayColumnRenderer = function(row, column, value, defaultHtml, columnProperties) { var element = $(defaultHtml); var content = jQuery.global.format(value, 'n'); element.text(content); if (element.length > 0) { return element[0].outerHTML; } return content;};
Currently I got rid of the error by stabbing the library file jqxgrid.edit, but it’s always bad idea:
case "numberinput": if (this.editcell.editor.jqxNumberInput) { var c = this.editcell.editor.jqxNumberInput("getDecimal"); // TODO: library modification! if (c != null || c != '') { c = c.replace(this.editcell.editor.jqxNumberInput("decimalSeparator"), "."); c = c.replace(this.editcell.editor.jqxNumberInput("groupSeparator"), ""); } f = new Number(c); f = parseFloat(f); if (isNaN(f)) { f = 0; } if (d.displayfield != d.datafield) { f = { label: f, value: f }; } } break; }
Hi alexz,
Thanks for the input. We will take a look into that code.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.