关于 Handsontable 条件格式
regarding Handsontable conditional Formatting
我有一个包含值的 Handsontable,我需要应用像 [=11=],0.00
这样的数字格式。使用下面的代码我能够实现它但是如果我将 renderer
应用于 cellproperty 单元格通过覆盖以前的单元格以新样式更改 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;
}
我想为格式化的单元格属性应用样式
每次对单元格进行更改时都会触发渲染器。这就是覆盖格式的原因。
更新
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';
};
我有一个包含值的 Handsontable,我需要应用像 [=11=],0.00
这样的数字格式。使用下面的代码我能够实现它但是如果我将 renderer
应用于 cellproperty 单元格通过覆盖以前的单元格以新样式更改 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;
}
我想为格式化的单元格属性应用样式
每次对单元格进行更改时都会触发渲染器。这就是覆盖格式的原因。
更新
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';
};