Lorraine Bernard
Lorraine Bernard

Reputation: 13400

Sets cell to be readonly

I am using jquery-handsontable to create a data-grid.

If I make

$("#example1grid").handsontable('setDataAtCell', 0, 0,"test")
$("#example1grid").handsontable("setCellReadOnly", 0, 0);

It changes the text but then when I click I can edit it. Why?

Here is the test http://jsfiddle.net/z9fYC/59/.
Anyway what about if I want to make all the column number 0 read-only? ​

Upvotes: 1

Views: 6593

Answers (2)

warpech
warpech

Reputation: 6433

It was a indeed a bug in Handsontable. It is fixed as of version 0.7.3

Upvotes: 4

fegemo
fegemo

Reputation: 2594

It does look like a bug. According to the documentation, what you did should work.

Anyways, to workaround, you can define the readonly behavior in a cell by cell basis, like this:

$("#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;        
    }
});

Upvotes: 7

Related Questions