一,列只读
js代码:
var container1 = document.getElementById(‘example1‘),
hot1;
hot1 = new Handsontable(container1, {
data: getCarData(),
minSpareRows: 1,
colHeaders: [‘Car‘, ‘Year‘, ‘Chassis color‘, ‘Bumper color‘],
columns: [
{
data: ‘car‘,
readOnly: true
},
{
data: ‘year‘
},
{
data: ‘chassis‘
},
{
data: ‘bumper‘
}
]
});
二,单元格 只读 (当前的单元格为‘Nissan‘时只读readOnly)
var container2 = document.getElementById(‘example2‘),
hot2;
hot2 = new Handsontable(container2, {
data: getCarData(),
minSpareRows: 1,
colHeaders: [‘Car‘, ‘Year‘, ‘Chassis color‘, ‘Bumper color‘]
});
hot2.updateSettings({
cells: function (row, col, prop) {
var cellProperties = {};
if (hot2.getData()[row][prop] === ‘Nissan‘) {
cellProperties.readOnly = true;
}
return cellProperties;
}
})
时间: 2024-10-25 11:08:48