datetimefield/dependent

datetimefield/dependent

crush123crush123 Posts: 417Questions: 126Answers: 18
edited November 2015 in Editor

following on from a previous thread

http://datatables.net/forums/discussion/31507/

I am having a problem with the editor (1.5.3) datetimefield/dependent

editor.dependent( 'tblevent.EventDate', function ( val ) {
        editor.field( 'tblevent.EventDateTo' ).val( val );
    },
    {event: 'change'}
    );

If I set the event to for example, focusout, the editor instance opens ok, but if I set it to change, the editor does not open, and I get an error

dataTables.editor.js:569 Uncaught TypeError: Cannot read property 'length' of undefined

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Interesting - I can reproduce that using this example with the following code (change is the default):

    editor.dependent( 'start_date', function ( val ) {
            console.log( editor.field( 'start_date' ).val( val ) );
    } );
    

    Sorry about this error! Let me look into it and I'll post back as soon as I've got the fix.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited November 2015

    Trying to think of a workaround

    What I want to do is set the value of additional date fields in my editor to the same as the start date on changing the start date value

    I tried adding the following code to my page

            $('input', editor.field('tblevent.EventDate').node()).on( 'change', function () {
            var value = editor.field('tblevent.EventDate').val();
            editor.field('tblevent.EventDateTo').set( value );
            editor.field('tblevent.ReplyDeadlineDate').set( value );
    
        } );
    

    but this gives me an error

    dataTables.editor.js:569 Uncaught TypeError: Cannot read property 'length' of undefined

    Also, a couple of general datapicker questions...

    is it possible to close the datepicker when tabbing through the editor ? - as my datepicker instance stays open unless i click.

    can i add dates going back prior to 2005 ?

    Thanks

    UPDATE

    I changed the datepicker, so I am now using the bootstrap-datetimepicker 2

    http://editor.datatables.net/plug-ins/field-type/editor.datetimepicker-2

    This is working well, no errors, but the code i posted above doesn't fire on change, (though it does fire on mouseover, on blur ...

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    I've just dropped you an e-mail about the above issue, but regarding this:

    is it possible to close the datepicker when tabbing through the editor ?

    That's a bug - will be fixed in 1.5.4 - thanks!

    can i add dates going back prior to 2005 ?

    Yes. The range can be extended using the opts.yearRange option of the datetime field type.

    Allan

This discussion has been closed.