Calendar setDate NOT working

I am having trouble with the following.
Basically IF the user forgets to Set the calendar, I want it to default to today, so:

var cal1 = form.getCalendar(“dt1”);
var d = new Date();
d.setDate(d.getDate() - 1);
cal1.setDate(d);

Althought IF I get use cal1.getDate() it returns the correct value, it does NOT show the date on the calendar.I have tried cal1.value(), cal1.label, etc …
I’ve been breaking my head on this for 3 days now!!!

Thank you
F

Hello
You need to transfer as parameter in setDate the whole date, not only day

Hy Darya, long time no speak!
I really don’t understand what you mean, can you pls give me an example?

Actually, if you look at my code, I AM passing the whole date!
I am passing “d” which is a date() object

Nice to see you too :slight_smile:
Could you provide us completed demo to inspect your issue?

I have the same problem.
Although the dhtmlXCalendar control does have the value but is not reflected in UI …

I’m using Knockout, but KO is not the problem

I using:
Product Name: dhtmlxSuite
Version: 5.0.2
Edition: Professional

ko.bindingHandlers.dhtmlXCalendar = {
    init: function (element, valueAccessor, allBindingsAccessor) {        
        var calendar = ko.utils.domData.get(element, 'dhtmlXCalendar');
        calendar.attachEvent("onChange", function (date, state) {
            // Este evento no lo lanza shit!!!
        });                
        calendar.attachEvent("onClick", function (date) {            
            var observable = valueAccessor();    
            observable(date);            
        });
    },
    update: function (element, valueAccessor) {
        var value = ko.utils.unwrapObservable(valueAccessor());
        var _calendar = ko.utils.domData.get(element, 'dhtmlXCalendar');        
        if (_calendar) {
            _calendar.setDate(value);
        }
    }
};

There are two cases

a) when calendar is in the dhtmlxform (original case of this topic), you need to use form.setItemValue API instead of direct calendar manipulation

snippet.dhtmlx.com/3ee178af7

b) when calendar is on its own, setDate sets date correctly

snippet.dhtmlx.com/10d5e5ad6