gportela85/DateTimeField

Empty value in record leads to error in setValue method of picker

Closed this issue · 3 comments

Hi,

If we bind a record with a field containing null as value for the datetime picker, the setValue() (or better the setSeconds(0) function) in Line 276 of DateTimePicker.js fails. Null is passed from the viewmodel record in the binding. For now, we created some kind of default pointing to a new date of today, but for new forms with a bunch of empty fields and one date-time-picker field predefined with the value of today this is not desired. Is it possible to check in the setValue method for null? Perhaps we simply miss a thing ?

Greetings

Olli

This should work for you

Ext.define('DateTimePicker',{
    override: 'Ext.ux.DateTimePicker',
    setValue: function(value) {
        value = value || new Date();
        value.setSeconds(0);   

        this.value = new Date(value);
        return this.update(this.value);
    }
});

I have a fiddle with this working here: https://fiddle.sencha.com/#fiddle/1bom

Hey cool, that was fast !... Thank you very much.

Olli