我想有条件地显示一个单元格的工具提示例如如果单元格值根据某些规则无效,则显示规则的文本,因为它无效。
var hot = new Handsontable(document.getElementById('example'), {
cells: function(row, col, prop) {
var cellProperties = {};
cellProperties.renderer = 'confirmTradePriceRederer';
return cellProperties;
}
});
function confirmTradePriceRederer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.NumericCell.renderer.apply(this, arguments);
if (value is invalid) {
td.style.color = 'red';
//set tooltip here somehow
}
}
您可以像这样使用td
工具提示:
td.title = 'tooltip'
我使用comments工作了:
var hot = new Handsontable(document.getElementById('example'), {
cells: function(row, col, prop) {
var cellProperties = {};
cellProperties.renderer = 'confirmTradePriceRenderer';
return cellProperties;
}
});
function confirmTradePriceRederer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.NumericCell.renderer.apply(this, arguments);
if (value is invalid) {
td.style.color = 'red';
cellProperties.comment = 'Test Comment';
}
}