Set empty value to date column onBeforeSave event

Hi support,
I am using date InlineEditor column. When I clear the value in Date column, I want to set empty value to it.
But now its again set the previous value.

gantt.ext.inlineEditors.attachEvent(“onBeforeSave”, function (state: any) {
if ( state.newValue == null) {
state.newValue=’’;
}
return true;
});

I added this code snippet , but it didn’t work.

Thanks,
Rasagb

  }

Hello,
The inline editor returns the previous value of the task, because for the task, start_date and end_date are required parameters. There is no built-in way to set an empty value to the date column, but you can implement it with the unsсheduled tasks which have no dates in Gantt:
https://docs.dhtmlx.com/gantt/desktop__unscheduled_tasks.html ;
And when the null value is set in the date column, you need to add the unscheduled property to the task and clear the start_date of the task. In the end, you need to update the task by updateTask method:
https://docs.dhtmlx.com/gantt/api__gantt_updatetask.html ;
Please check the example of how it might be implemented:
https://snippet.dhtmlx.com/2gjz2ol3

Hi ,

actually this column is a custom date column in Gantt. we need to do this without se task unscheduled.

Thanks.
Rasagb

Hello,
If you have the custom date, so you need to use the date inline editor with specified map_to: "custom_date" property:
https://docs.dhtmlx.com/gantt/desktop__inline_editing.html ;
And when the null value is set in the custom date column, you need to clear the custom_date of the task:

gantt.ext.inlineEditors.attachEvent("onBeforeSave", function (state) {
    let task = gantt.getTask(state.id);
    if (state.columnName == "custom_date" && state.newValue == null) {
        task.custom_date = "";
        gantt.updateTask(task.id)
    }
    return true;
});

Please check the following snippet:
https://snippet.dhtmlx.com/o3pwvj8p