将单元格设置为只读

Lor*_*ard 1 javascript jquery jquery-plugins handsontable

我正在使用jquery-handsontable来创建数据网格.

如果我做

$("#example1grid").handsontable('setDataAtCell', 0, 0,"test")
$("#example1grid").handsontable("setCellReadOnly", 0, 0);
Run Code Online (Sandbox Code Playgroud)

它会更改文本,但是当我单击时我可以编辑它.为什么?

这是测试http://jsfiddle.net/z9fYC/59/.
无论如何,如果我想让所有列号0都是只读的呢?

feg*_*emo 7

它确实看起来像一个bug.根据文档,你做了什么应该工作.

无论如何,要解决此问题,您可以逐个单元地定义只读行为,如下所示:

$("#example1grid").handsontable({
    rows: 5,
    cols: 6,
    minSpareCols: 1,
    //always keep at least 1 spare row at the right
    minSpareRows: 1,
    //always keep at least 1 spare row at the bottom
    contextMenu: true,
    cells: function(r,c, prop) {
        var cellProperties = {};
        if (r===0 && c===0) cellProperties.readOnly = true;
        return cellProperties;        
    }
});
Run Code Online (Sandbox Code Playgroud)