我有一个包含值的Handsontable,我需要应用数字格式,比如$0,0.00。使用下面的代码,我可以实现它,但如果我将renderer应用于单元格属性,则单元格会通过覆盖前一个单元格format.Please来更改新样式,告诉我正在做什么错误。
码
function inHeadRenderer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.TextCell.renderer.apply(this, arguments);
td.style.textAlign="left"
td.style.paddingLeft="1%";
td.style.fontWeight = 'bold';
td.style.fontSize="10px";
td.style.fontFamily= 'verdana';
td.style.background = '#FCFFFA';
td.style.color = '#0B610B';
}
cells: function (row, col, prop) {
if($("#handsontable").handsontable('getData')[col,row][num_cols-1] ==="Inflow"){
cellProperties={
type: 'numeric',
format:'0,0.00',
language: 'en'
}
return cellProperties;
}我想为格式化的单元格属性应用样式。
发布于 2015-05-25 08:19:00
每次对单元格进行更改时都会触发呈现器。这就是重写格式的原因。
更新
http://jsfiddle.net/hU6Kz/3519/是供您参考的工作代码。
更正。包括渲染器中的类型
inHeadRenderer=function(instance, td, row, col, prop, value, cellProperties) {
Handsontable.NumericCell.renderer.apply(this, arguments);
td.style.textAlign="left"
td.style.paddingLeft="1%";
td.style.fontWeight = 'bold';
td.style.fontSize="10px";
td.style.fontFamily= 'verdana';
td.style.background = '#FCFFFA';
td.style.color = '#0B610B';
cellProperties.type = 'numeric';
};https://stackoverflow.com/questions/30432921
复制相似问题