【问题标题】:Handsontable - text align on numeric cellsHandsontable - 数字单元格上的文本对齐
【发布时间】:2015-08-26 14:41:08
【问题描述】:

我正在使用 handsontable 在类似 ASP.NET MVC Excel 的应用程序中编辑数字数据。 我通过此代码设置单元格格式:

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;
    }
});

此行设置的数字格式:

cellProperties.type = "numeric";  
cellProperties.format = '0.00';  
cellProperties.language = 'ru';  

之后,在本地开发环境(由 Visual Studio 运行的 IIS Express)上,所有数字都对齐。但在生产服务器上 - 所有数字都左对齐。我做错了什么?

【问题讨论】:

    标签: javascript asp.net handsontable


    【解决方案1】:

    问题已解决。

    开发和生产服务器上不同的语言环境导致的不同数字呈现。在开发机器上,数据库使用点“。”作为小数点分隔符,在生产服务器 DB 上使用逗号“,”作为小数点分隔符。通过设置正确的语言环境重新创建生产数据库来解决。

    【讨论】:

      猜你喜欢
      • 2015-06-13
      • 2018-04-22
      • 2012-11-07
      • 2013-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-18
      • 2010-12-14
      相关资源
      最近更新 更多