Context: When I use “checkbox” as columns type I can use space to toggle On/Off the checkbox, but if I use my custom function it doesn’t work even if it points to the same function.
// PXDataviewerConfiguration
function PXDataviewerConfiguration(){
columnTypes: {
...
checkbox: ['PXCheckbox'],
...
},
fieldType: {
...
checkbox: function() {
return {
type: 'PXCheckbox', -> If I move it back to 'checkbox' it works with space/enter.
checkedTemplate: 1,
uncheckedTemplate: 0
};
},
...
}
};
In the PXCheckbox I did point it to the original one for testing and the space/enter doesn’t work even if they point to the original checkbox (editor/renderer).
// HandsontableCellTypes services
Handsontable.cellTypes.registerCellType('PXCheckbox',{
editor : Handsontable.editors.CheckboxEditor,
renderer : Handsontable.renderers.CheckboxRenderer,
});
If we look at the Handsontable code we see that Checkbox cell type also only contain editor / renderer (no extra validation)
// Handsontable core code
Handsontable.CheckboxCell = {
editor: getEditorConstructor('checkbox'),
renderer: getRenderer('checkbox')
};
The setup does work since I can click/use them and they do render, just not Space toggle them.
What I understood is that even if we extend the function or even use the direct reference Handsontable.renderers.CheckboxRenderer
the following Hook never get trigger.
// Handsontable core code CheckboxRenderer function
if (!isListeningKeyDownEvent.has(instance)) {
isListeningKeyDownEvent.set(instance, true);
instance.addHook('beforeKeyDown', onBeforeKeyDown);
}
function onBeforeKeyDown(event) {
var toggleKeys = 'SPACE|ENTER';
var switchOffKeys = 'DELETE|BACKSPACE';
Why does a custom checkbox that point to the same renderer does not work like the default one? Anything obvious I missed?
Thanks
Mathieu