我有一个可以处理一些onChange
事件并且运行良好的函数。该函数调用另一个函数来检查单元格的内容,如果有问题,则应更改单元格的颜色。
function Check(x, y)
{
var content = $editorTableContainer.handsontable('getDataAtCell', y, x);
var split = content.split(' ');
$.each(split, function (key, value) {
$.get('check.php?word=' + value, function (data) {
//blank if no error otherwise it returns an array of suggestions (only need to check if there is an error)
if (data) {
alert("test");
var meta = $editorTableContainer.handsontable('getCellMeta', y, x);
meta.renderer = ErrorRenderer;
}
});
});
return;
}
这是我简单的ErrorRenderer:
function ErrorRenderer(instance, td, row, col, prop, value, cellProperties)
{
Handsontable.TextCell.renderer.apply(this, arguments);
console.log(row);
td.style.fontWeight = 'bold';
td.style.color = 'green';
td.style.background = '#CEC';
}
永远不会调用ErrorRenderer,即使触发了警报,也知道为什么吗?
谢谢
如果您使用的是handontable,为什么不使用其内置功能?
看看HT的条件格式
同样,在0.9.5版中添加了column选项validator
。详细信息在这里。
validator (value: Mixed, callback: Function)
或者
validator : RegExp Object
然后使用该事件(在此处查看详细信息):
afterValidate (isValid: Boolean, value: Mixed, row: Number, prop: String, source: String)
进行单元格格式化
另外,在您的示例中,您正在设置渲染器,但是单元格实际上正在渲染吗?您需要重新渲染吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句