【发布时间】:2015-10-17 18:02:39
【问题描述】:
我有一个 Handsontable 网格,用户将在其中输入一些值以将它们插入数据库。当他提交网格时,我希望特定单元格为“只读”。在这种情况下,我希望第一列是“只读”。
我使用 Ajax 将我的数据发送到我的数据库中。在我的回调函数中,我想将单元格属性编辑为“只读”。
所以我现在拥有的是:
var cellProperties={};
var i;
for (var i = 0; i < data_traitement.length; i++) {
cellProperties.readOnly = true;
return cellProperties;
}
但“cellProperties”选项只能在 Handsontable 定义中使用。所以我不知道用什么来做到这一点。
有人可以帮帮我吗?
编辑:
在 ZekeDroid 的建议下,我尝试修改我的单元格定义: 所以我有这个:
cells:function(row,col,prop){
var cellProperties = {};
if ([0].indexOf(row) !== -1 && col >= 0)
{
cellProperties.readOnly = true;
}
if (readOnlyCells[[row,col]]) {
cellProperties.readOnly = true;
}
return cellProperties;
}
在我的回调函数中,如果我理解的很好,我要把这个readOnlyCells改成true。
所以我做了这个:
for (var i = 0; i < data_traitement.length; i++) {
readOnlyCells[[i,0]] = true; //I'm not sure of this line
}
hot.render();
【问题讨论】: