Datatable editor datetime field property nullDefault isn't working.

Datatable editor datetime field property nullDefault isn't working.

shashankVshashankV Posts: 4Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: I want to remove editor datetime field default selection of today's date because of that on change event triggers without even changing the date from the datepicker.

Field Declaration:
{
label: "Scheduled Complete:",
name: "sched_complete",
type: "datetime",
format: 'M-D-YYYY',
id: "sched_complete_date",
nullDefault: true,
}

On change event
$('#sched_complete_date').on('change', function(e, d){
new_date = moment(d.write).format("M-D-YYYY")
console.log('old value', old_value, new_date)
if(new_date != undefined && new_date != null && new_date != old_value){
editor.field('schedule_date_change_reason').enable();
}
});

Answers

  • allanallan Posts: 56,837Questions: 1Answers: 9,035 Site admin

    No matter what you have for the field.def value for a field, it will always trigger a change event when a create form is shown. You can check the second parameter in your change event callback to determine if it is a programmatic set for user set. If it is defined then it is programmatic. If not set, then it is due tot he end user selecting a value.

    Allan

Sign In or Register to comment.