如何在handsontable中使用handsontable禁用特定列。我只希望第一列可编辑,其他三列被禁用。我对三列使用readonly true,但它不适用于如何禁用...
columns: [
{
type:'handsontable',
handsontable: {
colHeaders: ['EmployeeNo','EmployeeName','Department','Designation'],
data: manufacturerData,
columns:[{},{readOnly: true},
{
readOnly: true
},
{
readOnly: true
}]
}
},
{}]发布于 2013-12-16 20:27:47
在Project中,我用下面这行代码做这件事。
cells : function(row, col, prop) {
var cellProperties = {};
if (col > 0) {
cellProperties.readOnly = true;
}
else
{
cellProperties.readOnly = false;
}
return cellProperties;
}你可以在给定的链接上找到它的工作示例。但给出的示例是将行设置为只读。http://handsontable.com/demo/conditional.html
发布于 2015-07-01 19:30:32
您的代码运行正常。请使用与您类似的方法查看JSFiddle。
$("#test").handsontable({
startRows: 1,
startCols: 1,
rowHeaders: true,
colHeaders: true,
minSpareCols: 0,
minSpareRows: 0,
contextMenu: false,
fillHandle: false,
outsideClickDeselects: false,
removeRowPlugin: false,
currentRowClassName: 'currentRow',
currentColClassName: 'currentCol',
columnSorting: true,
colHeaders: ['Col1','Col2','Col3','Col4'],
columns: [{},
{readOnly: true},
{readOnly: true},
{readOnly: true}]
});工作链接:http://jsfiddle.net/rvd61fuy/
如果你面临任何其他问题,请让我知道。
发布于 2014-09-15 19:55:57
要禁用此功能,您可以将单元格/列设置为只读,甚至可以将背景颜色设置为灰色(以获得特殊效果),即在初始化handsontable时在列声明中使用.Both:true的方法,以及使用单元格属性和使用条件来确定是否需要将单元格设置为只读的方法,这两种方法似乎都适用于me.You,但这两种方法都需要正确实例化您的HOT,这可能是问题所在。此外,在使用单元格属性时,您不需要使用cellProperties.readOnly = false,因为默认情况下,单元格不是只读的,除非您为其单独编码。如果您需要进一步的帮助,请告诉我。
https://stackoverflow.com/questions/19787297
复制相似问题