I have a boolean type property in the task object and I'd like to add a checkbox in the general tab to set the value.
I was trying to set it to try by default and let the user uncheck it, but my code doesn't work as expected. When I add a new task and uncheck the checkbox, in the edit it's still checked.
Is there a solution to this? I know I'm doing something wrong, but I cannot find documentation about this.
I add here part of my code, I also have another custom field which works fine.
if (args.requestType === "beforeOpenEditDialog" || args.requestType === "beforeOpenAddDialog") {
//add the status dropdown
var column = this.ganttInstance.columnByField["Status"];
this.divElement = this.ganttInstance.createElement("div", {
className: "e-edit-form-column"
});
var inputElement;
inputElement = this.ganttInstance.createElement("input", {
attrs: {
type: "text",
id: this.ganttInstance.controlId + "" + column.field,
name: column.field,
title: column.field
}
});
this.divElement.appendChild(inputElement);
var input = {
enabled: true,
floatLabelType: "Auto",
placeholder: "Stato",
value: args.rowData.Status ? args.rowData.Status : this.Statuses[0],
dataSource: this.Statuses
};
var inputObj = new this.inputs[column.editType](input);
inputObj.appendTo(inputElement);
//add the notification checkbox
var notificationColumn = this.ganttInstance.columnByField["Notification"];
this.divElement2 = this.ganttInstance.createElement("div", {
className: "e-edit-form-column"
});
var notificationCheckboxElement;
notificationCheckboxElement = this.ganttInstance.createElement("input", {
attrs: {
type: "checkbox",
label: "Notifica",
id: this.ganttInstance.controlId + "" + notificationColumn.field,
name: notificationColumn.field,
title: notificationColumn.field
}
});
if (args.requestType === "beforeOpenEditDialog") {
args.rowData.Notification = args.rowData.Notification === true;
} else {
args.rowData.Notification = true;
}
this.tempNotification = args.rowData.Notification;
this.divElement2.appendChild(notificationCheckboxElement);
var notificationCheckbox: CheckBoxModel = {
label: "Notifica",
value: args.rowData.Notification,
checked: args.requestType === "beforeOpenEditDialog"?args.rowData.Notification:true,
change: (args: any) => { this.tempNotification = args.checked; }
};
var notificationCheckboxObj = new this.inputs[notificationColumn.editType](notificationCheckbox);
notificationCheckboxObj.appendTo(notificationCheckboxElement);
And in the beforeAdd I do this:
let Notification = this.tempNotification;
args.newTaskData.Notification = this.tempNotification;
While in the beforeSave:
let Notification = this.tempNotification;
args.modifiedTaskData[0].modifiedTaskData.Notification = this.tempNotification;
Thank you in advance if you have a solution.
Matteo Messmer