我正在尝试在SlickGrid中的某些项目上实现更新colspan:
这部分代码工作正常:
dataView.getItemMetadata = function (row) {
if (0 == 0) {
return {
"columns": {
"heading": {
"colspan": "*"
}
}
};
} else {
return {
"columns": {
"heading": {
"colspan": 1
}
}
};
}
};
它为所有项目提供了预期的colspan,但我希望在"突出显示"列并使用它来确定"标题"列获得了一个colspan应用。每次单击高亮显示列中的复选框时,都需要更新。所以我需要获得"突出显示"的价值。那一行的专栏。
如果我这样做:
console.log(dataView.getItem(row));
我得到了这样的多个项目:
Object {id: "id_5", highlight: 1, heading: "voluptatem", quoted: 0…}
但如果我这样做:
console.log(dataView.getItem(row).highlight);
我明白了:
Uncaught TypeError: Cannot read property 'highlight' of undefined
我的问题是,我是否以正确的方式进行此操作,如果是这样,我如何在"突出显示"中获取单元格的值。列和"行"行?
答案 0 :(得分:0)
我需要将当前if语句包装在另一个if语句中:
if (typeof data[row] != "undefined") {
//original if
}
确保该行实际存在