So the checkbox isn't binding to the field in a way I would predict.
If I create a new event it isn't checked, on existing events it's checked regardless of the underlying value.
I was able to override the visibility of the checkbox in the "beforeEventEditShow" event.
Although this isn't working for the checkbox.
Relevant code is pasted below:
let checkboxIsUnAvailable = new Checkbox({
id : 'isUnavailable',
name : 'isUnavailable',
field : 'isUnavailable',
ref : 'isUnavailableCheckbox',
type : 'checkbox',
label : 'Is niet beschikbaar',
value : 1
});
eventEdit : {
onAfterSave(eventRecord) {
schedule.crudManager.sync();
},
extraItems : [
checkboxIsUnAvailable
]
},
listeners: {
beforeEventEditShow: function (source, eventEdit, eventRecord, resourceRecord, eventElement, editor) {
const checkboxVisible = source.eventRecord.code === undefined || source.eventRecord.code.length === 0;
checkboxIsUnAvailable.visible = checkboxVisible;
// Doesn't work
checkboxIsUnAvailable.checked = parseInt(source.eventRecord.isUnavailable) == 1;
// Also Doesn't work
if (parseInt(source.eventRecord.isUnavailable) == 1) {
checkboxIsUnAvailable.check();
} else {
checkboxIsUnAvailable.uncheck();
}
//console.log(parseInt(source.eventRecord.isUnavailable) == 1);
},
}