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fTzf1/AbX2dtdFAeudHKjJbyKcxHTo2X6tfps7an3ZhqrbytPlwX4MqtrT58pjT1j39uqVZ/tlPN7PLIXaD9AV1dbvwuJtT8rd4td1DZx8dDBlY6pyZ+oPYuZQ8Ba/rmsm3wymbExV7mS2ZkueURb5vCOEyTeCKRtTlTu0RcLkG8GUjanKHdoiYfKNYMrGVOUObZEw+UYwZWOqcoe2SCCSTwjZHv/kL+9kezBlY6pyh7ZImHwjmLIxVblDWyRMvhFM2Ziq3KEtEibfCKZsTFXu0BYJk28EUzamKndoi4TJN4IpG1OVO7RFwuQbwZSNqcod2iJh8o1gysZU5Q5tkTD5RjBlY6pyh7ZImHwjmLIxVblDWyRMvhFM2Ziq3KEtEibfCKZsTFXu0BYJk28EUzamKndoi4TJN4IpG1OVO7RFwuQbwZSNqcod2iJh8o1gysZU5Q5tkTD5RjBlY6pyh7ZImHwjmLIxVblDWyRMvhFM2Ziq3KEtEibfCKZsTFXu0BYJk28EUzamKndoi4TJN4IpG1OVO7RFApF8Qsj2OCefEFIcTD4he4TJJ2SPMPmE7BEmn5A9wuQTskeYfEL2CJNPyB5h8gnZI0w+IXuEySdkjzD5hOwRJp+QPcLkE7JHVkj+X1I+y4cBKQsmn/z9y+Tvj/8BBzB1rDzb8rsAAAAASUVORK5CYII=" alt="" />
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)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVYAAAC2CAIAAAAN/jLiAAAPfUlEQVR4nO2dPXLruhKEvZazBq3C4dsCF6DQq1DZdfegXIkib+FWucqhVuDopC/EDSSRAGbAvwE5TbO/cnAMS1CrCTRAyJ7zEgghO+bF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BVM2pip3aIuEEWAFUzamKndoi4QRYAVTNqYqd2iLBCsCCFmU//3zf37Jr4Xmf+AuwBFMVe64TzbMr+UMZwS4ganKnaVH/OZgBFQAUzamKncYARmMgApgysZU5Q4jIIMRUAFM2Ziq3GEEZDACKoApG1OVO4yADEZABTBlT1AF9odri8IIyGAEVABTdq6K1bJDCIwAASOgApiytQjYe7XswAgQMAIqgClbjYCdV8sOjAABI6ACmLL1CNh3tezACBAwAiqAKbsUAXuulh0YAQJGQAUwZZcjYL/VsgMjQMAIqACm7J4I2G217MAIEDACKoApuzcCdlotOzACBIyACmDKHoiAXVbLDowAASOgApiyMVW5wwjIYARUAFM2pip3GAEZjIAKYMrGVOUOI2BlGAFuYKpyhxGwMowANzBVucMIiFmhgiAjwA1MVe64F+oE+VLdWMJwFhEnWLjPPZCv+4xDjIAlRCwNpmxMVe7QlhhGQB0wZWOqcoe2xDAC6oApG1OVO7RlZRgBbmCqcoe2rAwjwA1MVe7QFsminjAC3MBU5Q5tkTACrGDKxlTlDm2RMAKsYMrGVOUObZEwAqxgysZU5Q5tkTACrGDKxlTlDm2RMAKsYMrGVOUObZEwAqxgysZU5Q5tkTACrGDKxlTlDm2RMAKsYMrGVOUObZEwAqxgysZU5Q5tkTACrGDKxlTlDm2RMAKsYMrGVOUObZEwAqxgysZU5Q5tkTACrGDKxlTlDm2RMAKsYMrGVOUObZEwAqxgysZU5Q5tkTACrGDKxlTlDm2RYEUAIWR9Fpr/YWoEEEJ+GYwAQnYNI4CQXcMIIGTXMAII2TWMAEJ2DSOAkF3DCCBk1/wHGpbpW4WIyTwAAAAASUVORK5CYII=" alt="" />
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;
}
})