This may be interest to others. I have single column that by default I want word wrapping turned off. Then when a cell is selected I want word wrapping enabled, when I exit the cell I want word wrapping turned off for that cell.
Handsontable version 14.3.0 Javascript.
(editor_sheet is the Handsontable reference)
The following worked for me.
When loading the table. Set each cell in the column to:
editor_sheet.setCellMeta(index, output_idx, ‘className’, ‘htNoWrap’);
I then added two hook handlers.
editor_sheet.addHook(‘afterOnCellMouseDown’, function(ev) {
var selected = editor_sheet.getSelected();
if (selected != null) {
var item = selected[0];
header_row = editor_sheet.getDataAtRow(0);
output_idx = header_row.indexOf(‘output’);
if (item[1] == output_idx) && (item[3] == output_idx) {
var row = Math.min(item[0], item[2]);
editor_sheet.setCellMeta(row, output_idx, ‘className’, ‘htWrap’);
editor_sheet.render();
};
};
});
editor_sheet.addHook(‘afterOnCellMouseOut’, function(ev) {
var selected = editor_sheet.getSelected();
if (selected != null) {
var item = selected[0];
header_row = editor_sheet.getDataAtRow(0);
output_idx = header_row.indexOf(‘output’);
if (item[1] == output_idx) && (item[3] == output_idx) {
var row = Math.min(item[0], item[2]);
editor_sheet.setCellMeta(row, output_idx, ‘className’, ‘htNoWrap’);
editor_sheet.render();
};
};
});