Here is an interesting one…
I’ve been using a custom plugin to set the title of a cell when it has an error. It works for everything, except for frozen columns:
export class ErrorTitlePlugin extends BasePlugin {
public static get PLUGIN_KEY() {
return 'errortitle';
}
public enablePlugin() {
this.addHook(
"afterValidate",
(isValid: boolean, value: CellValue, row: number, prop: number | string, source: ChangeSource) =>
this.onAfterValidate(isValid, value, row, prop, source)
);
super.enablePlugin();
}
public isEnabled() {
const settings = this.hot.getSettings() as TGridSettings;
return settings['errortitle'];
}
// this is called externally, eg in a validator function
public setErrorTitle(cell: CellProperties, errors: string) {
this.hot.setCellMeta(cell.visualRow, cell.visualCol, 'errortitlekey', title);
}
// this works for everything except frozen columns
private onAfterValidate(
isValid: boolean,
_value: CellValue,
row: number,
prop: number | string,
_source: ChangeSource
) {
const col = this.hot.propToCol(prop) as number;
const cell = this.hot.getCell(row, col);
if (cell) {
if (isValid) {
cell.removeAttribute("title");
} else {
const meta = this.hot.getCellMeta(row, col);
cell.title = meta['errortitlekey'] ?? "";
}
}
}
}
Anyway, when I log out cell above in onAfterValidate
I do see an HTML TD element with the title set, yet something after-the-fact is removing this… it must be when it renders the column because it is frozen, it for some reason removes the title. I guess “afterValidate” is probably called before whatever freezes columns… I wonder if there is another hook I can use to maintain this, or if we can fix the renderer of frozen columns to preserve custom HTML attributes…