Disabled Editor field with plugin
Disabled Editor field with plugin
I have a DatetimePicker using a plug in:
var editor_exportsets = new $.fn.dataTable.Editor({
fields: [ {
label: "Date/Time:",
name: "schedule.onceDateTime",
type: "datetime",
labelInfo: "(YYYY-MM-DD HH:mm)",
opts: {
pick12HourFormat: false,
useSeconds: false,
format: 'YYYY-MM-DD HH:mm'
}
I want to disable it when the form is busy. I tried this but it didn't work:
editor_exportsets.disable(['schedule.onceDateTime' ]);
The datepicker has its own disabled function but I'm not sure how to deploy it.
$('#datetimepicker3').data("DateTimePicker").disable();
Do i add a "disable" and "enable" function in the plug-in editor.datetimepicker.js?
$.fn.dataTable.Editor.fieldTypes.datetime = $.extend( true, {}
$.fn.dataTable.Editor.models.fieldType, {
"create": function ( conf ) {
var that = this;
conf._input = $(
'<DIV class="input-group date" id="'+conf.id+'">'+
'<INPUT type="text" class="form-control" />'+
'<SPAN class="input-group-addon"><SPAN class="glyphicon"></SPAN>'+
'</SPAN>'+
'</DIV>'
)
.datetimepicker( $.extend( {}, conf.opts ) );
return conf._input[0];
},
"get": function ( conf ) {
return conf._input.find('input').val();
},
"set": function ( conf, val ) {
conf._input.find('input').val( val );
},
// Non-standard Editor methods - custom to this plug-in. Return the jquery
// object for the datetimepicker instance so methods can be called directly
inst: function ( conf ) {
return conf._input;
}
} );
This discussion has been closed.
Answers
Hi,
What you should be able to do is:
The
inst()
method will return the stored_input
parameter from the field type plug-in here - the jQuery object for the date time picker.Alternative you could use:
(assuming that
id
is correct).Regards,
Allan
Almost worked but got me further along. This was what did it:
the inst method was key so thanks for suggesting it.
Great thanks - I'll update the plug-in to return the
DateTimePicker
data.Allan