Unable to disable date field(datepicker) inline data table

Unable to disable date field(datepicker) inline data table

alexander.treyner@pdgm.comalexander.treyner@pdgm.com Posts: 2Questions: 2Answers: 0
edited February 2015 in Editor

Hi,
I'm try to disable date field(datepicker) in datatable and it's always enable .
code :
fieldType.date = $.extend.......

"disable": function (conf) {
$.datepicker ?
conf._input.datepicker("disable") :
$(conf._input).prop('disable', true);
}

and JS call :

editor.disable("Start_Date");
  • all other fields works good the problem only in date field.

second question, can I change type of datepicker?

Please help..
Thanks

Answers

  • chris_nchris_n Posts: 53Questions: 3Answers: 0

    I've run into the same issue. A date field defined thus:

    {
        "label": "Date Created",
        "name": "date_created",
        "type": "date",
        "dateFormat": "dd-mm-yy"
    },
    

    does not disable when modified like:

    editor.on( 'initEdit', function () {editor.disable('date_created');} )
    

    Chris

  • chris_nchris_n Posts: 53Questions: 3Answers: 0

    This question should probably be in the Editor category.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I've just been experimenting with this in my jQuery UI dates demo and it seems to work as expected for me.

    For example, open the console on that page and enter:

    editor.on( 'initEdit', function () {editor.disable('registered_date');} )
    

    Then select a row and edit it. The Registered date field is disabled.

    Are you able to link me to a test page which shows the issue so I can debug it or otherwise tell me how I can reconstruct the issue?

    Thanks,
    Allan

  • chris_nchris_n Posts: 53Questions: 3Answers: 0

    Indeed it does work on the demo. However, I am using bootstrap and the demo is not. Is it possible that is causing some issue? Otherwise, I load up the libraries in the same order the demo does.

    Your code also appears to work with the bootstrap demo however the start_date field does not appear to be a date field but a text field, and the problem I see is a date field problem.

    I'll try to work up a link back to the page in question tomorrow.

    Thanks for your help.

    Chris

  • chris_nchris_n Posts: 53Questions: 3Answers: 0
    edited February 2015

    Incidentally, executing

    editor.on( 'initEdit', function () {editor.disable('date_created');} )
    

    In the webconsole after page load of the page in my app does not work either.

    I load the html into that particular division #main_content through a

    $('#main_content').load(plugInName)
    

    The resulting table is then loaded by a '$(document).ready' function in the newly loaded content. I wonder if something might be getting borked during that process?

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Are you using a plug-in rather than the built in date input field type. If so, which plug-in are you using?

    Allan

  • chris_nchris_n Posts: 53Questions: 3Answers: 0

    Are you using a plug-in rather than the built in date input field type

    No. This is a plug-in system I'm using for my app. It does not extend/etc. DT or the editor.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Ah - got it. Thanks for the clarification and following up on this.

    Here is a little fix polyfill that you can run after you load Editor that will address this until I release 1.4.1 (which hopefully won't be far into the future - i.e. next week):

    $.fn.dataTable.Editor.fieldTypes.date.enable = function ( conf ) {
        $.datepicker ?
            conf._input.datepicker( "enable" ) :
            $(conf._input).prop( 'disabled', false );
    };
    
    $.fn.dataTable.Editor.fieldTypes.date.disable = function ( conf ) {
        $.datepicker ?
            conf._input.datepicker( "disable" ) :
            $(conf._input).prop( 'disabled', true );
    };
    

    Allan

  • chris_nchris_n Posts: 53Questions: 3Answers: 0

    Fixed!

    Thanks!

    Chris

This discussion has been closed.