2012-10-29 22 views
1

我使用jQuery的handsontable創建一個數據網格。集小區是隻讀

如果我讓

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

當我點擊我可以編輯它改變了文本,但隨後。爲什麼?

下面是測試http://jsfiddle.net/z9fYC/59/
無論如何,如果我想讓所有列號爲0只讀?

回答

7

它看起來像一個錯誤。根據文件,你做了什麼應該工作。

不管怎麼說,要解決,你可以通過細胞的基礎細胞中的定義只讀行爲,像這樣:

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

好的解決方法!當然,對於第一列中的所有單元格是隻讀的,** if **語句應該是「if(c === 0)'而不是。 – andrux

+0

感謝您提出這個問題。 – RayLoveless

4

這是一個Handsontable確實是一個錯誤。它被固定爲版本0.7.3