javascript - 出现错误未捕获的错误:尝试在单元格中添加渲染器时单元格类型必须是字符串 Handsontable
问题描述
我有一种情况,我必须根据几个条件在单元格中添加不同的渲染器。所以解决这个问题我已经完成了以下步骤;
makeHighlight(rowNum,colNum, highlightFor = '')
{
var root = this;
handsOnTable.updateSettings({
cells: function (row, col) {
var cellProperties = {};
//if for row never cell property set means
sheetConfig.cellProperties[row] == undefined
if(sheetConfig.cellProperties[row] == undefined)
sheetConfig.cellProperties[row] = [];
//If row number and column number matches
if (row == rowNum && col == colNum) {
if(highlightFor == 'condition1')
{
cellProperties = {
type : {
renderer : root.renderer1
}
}
sheetConfig.cellProperties[row][col] = cellProperties;
}
if(highlightFor == 'condition2')
{
cellProperties = {
type : {
renderer : root.renderer2
}
}
sheetConfig.cellProperties[row][col] = cellProperties;
}
if(highlightFor == 'condition3')
{
cellProperties = {
type : {
renderer : root.renderer3
}
}
sheetConfig.cellProperties[row][col] = cellProperties;
}
}
else
{
if(sheetConfig.cellProperties[row][col] != undefined)
{
cellProperties = sheetConfig.cellProperties[row][col];
}
}
return cellProperties;
}
});
}
现在我的渲染器功能是;
renderer1(instance, td, row, col, prop, value,cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
//td.style.background = '#ffff00';
td.style.background = '#ffff0091';
};
renderer2(instance, td, row, col, prop, value,cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.style.background = '#FF9999';
};
renderer3(instance, td, row, col, prop, value,cellProperties)
{
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.style.background = '#FFFF33';
};
现在的问题是我收到一个错误;
未捕获的错误:单元格类型必须是字符串
你能帮我解决我做错了什么吗?我试图弄清楚,但仍然没有运气。
任何帮助对我来说都会很棒。
提前致谢。
解决方案
推荐阅读
- php - Directus CMS 应用程序的自定义身份验证
- javascript - 如何在屏幕调整大小时重新计算变量?
- sql - 如何使用 Oracle SQL 从一列值中查找多个字符串
- authentication - 如何在 Ubuntu 上使用公钥和密码设置 SFTP
- database - 为 google-app-engine 存储大量图像的最佳方法是什么?
- python - numpy: referencing elements in reverse order
- python - Function which eliminates specific elements from a list in an efficient way
- javascript - How do I close a React Native Modal?
- reactjs - Nextjs 路由与 activeClassName 和 Ant Design 菜单
- python - 如何判断 apply_async 函数是否已启动,或者它是否仍在使用 multiprocessing.Pool 的队列中