【发布时间】:2016-12-03 22:07:48
【问题描述】:
我正在尝试为同一个可动手操作的单元格自定义渲染器和数字格式,但没有成功。指定自定义渲染器或数字格式都可以正常工作,但将两者应用于同一单元格时,数字格式将被忽略。
这是一个演示问题的简单示例代码。没有 cellProperties.renderer = firstRowRenderer; 1.5 正确显示为 1,50 €,而该行显示为 1.5(粗体绿色)。
JSP
<div id="exampleGrid"></div>
Javascript
function firstRowRenderer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.style.fontWeight = 'bold';
td.style.color = '#177B57';
td.style.background = '#CEC';
}
var contExample = document.getElementById("exampleGrid");
var ExampleHOT;
var language = {
delimiters: {
thousands: '.',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return '.';
},
currency: {
symbol: '€'
}
};
if (typeof window !== 'undefined' && this.numeral && this.numeral.language) {
this.numeral.language('de', language);
}
function ExampleTable(){
ExampleHOT = new Handsontable(contExample,{
data: [ [1.5], [] ],
rowHeaders: true,
colHeaders: true,
cells: function (row, col, prop) {
var cellProperties = {};
cellProperties.renderer = firstRowRenderer; // removing this line makes the format work
cellProperties.type = 'numeric';
cellProperties.format = '0.00 $';
cellProperties.language = 'de';
return cellProperties;
}
});}
ExampleTable();
有没有人找到解决方案? 非常感谢!
【问题讨论】:
标签: javascript jsp format handsontable renderer