I'm using handsontable for editing numeric data in ASP.NET MVC Excel-like app. I set up cell format by this code:
numeral.language('ru', {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return number === 1 ? 'er' : 'ème';
},
currency: {
symbol: '€'
}
});
var container = document.getElementById('hot');
var workflowActionType = '@ViewBag.WorkflowActionType';
var hot = new Handsontable(container,
{
data: data,
maxRows: 32,
colWidths: [500, 60, 100, 100, 100, 100],
cells: function (row, col, prop) {
var cellProperties = {};
cellProperties.type = "numeric";
cellProperties.format = '0.00';
cellProperties.language = 'ru';
if (row === 0) {
cellProperties.renderer = headerRowRenderer;
cellProperties.readOnly = true;
}
if (col === 0 && (row !== 0 || row !== 1)) {
cellProperties.readOnly = true;
}
if (row === 1) {
cellProperties.renderer = numberRowRenderer;
cellProperties.readOnly = true;
}
if (col === 1 && row !== 0 && row !== 1) {
cellProperties.renderer = rowCodeRenderer;
cellProperties.readOnly = true;
}
if ((col === 2 || col === 3 || col === 4 || col === 5) &&
(row === 0 || row === 1)) {
cellProperties.readOnly = true;
}
return cellProperties;
}
});
Numeric format sets by this line:
cellProperties.type = "numeric";
cellProperties.format = '0.00';
cellProperties.language = 'ru';
After that, on local development environment (IIS Express runned by Visual Studio) all numbers aligned right. But on production server - all numbers are aligned left. What I'm doing wrong?
Problem resolved.
Different number rendering caused by different locales on development and production server. On development machine, DB uses dot "." as decimal separator, and on production server DB uses comma "," as decimal separator. Solved by recreate production database with setting correct locale.