Scheduler addEvent

Hi,

I work on web mobile application and i use the mobile scheduler. I worked with the ‘desktop’ scheduler with which I have’t had a problem.

But, With the mobile scheduler, I can’t create Event dynamically .

I tried :

$$(“scheduler”).parse([
{ id: 1, start_date: “2012-08-15 06:00”, end_date: “2012-08-15 12:00”, text: “Event 1” },
{ id: 2, start_date: “2012-08-16 06:00”, end_date: “2012-08-16 12:00”, text: “Event 2” }
], “json”);

And

scheduler.addEvent({
id: “ev123”,
start_date: “19-08-2012”,
end_date: “19-08-2012”,
text: “My new event. dhtmlxScheduler release”
});

but it doesn’t work… :frowning:

Can someone help me ?

Thx…

additional questions : there is mobile scheduler in scheduler ASP.NET ?

Hi,

the first method works. The second one uses incorrect date format for start_date and end_date.

Possibly you you did not define init_date. And in this case the “List” view of Scheduler displays events that start since today date:

scheduler.config.init_date = new Date(2012,7,1);

thx for reply,

This is how I use it :

scheduler.config.init_date = new Date(); // => DateTime.Now();

dhx.ready(function(){
        dhx.ui({
            view: "scheduler",
            id: "scheduler",
            scroll: true,
            container: "divScheduler"
        });

        dhx.i18n.fullDateFormat = "%d-%m-%Y %H:%i";
        dhx.i18n.setLocale();

        $$("scheduler").load("", "scheduler");
    });

    $$('scheduler').$$('month').show();
    $$('scheduler').$$('buttons').setValue('month');

    $$("scheduler").$setSize(contentWidth, contentHeight - OFFSET_HEIGHT);

$$("scheduler").$$("calendar").attachEvent("onAfterMonthChange", function (newDate, oldDate) {
        PageMethods.PopulateScheduler(SuccessPopulateScheduler, FailurePopulateScheduler);
    })



(...)


function SuccessPopulateScheduler()
{
$$("divScheduler").parse([
                { id:1, start_date:"2012-8-14 6:00", end_date:"2012-8-14 8:00", text:"Event 1", details:"details here"},
                { id:2, start_date:"2012-8-15 18:00", end_date:"2012-8-16 20:00", text:"Event 2", details:"details here"}
                ],"json");

$$("scheduler").refresh();

}

When I debug, I pass in the method, but it does not work… No Events are added… I’m desperate…

thx for your help…

You are calling loading method before Scheduler initialization. You need to call it inside dhx.ready:

[code]dhx.ready(function(){
dhx.ui({
view: “scheduler”,
id: “scheduler”,
scroll: true,
container: “divScheduler”
});

    dhx.i18n.fullDateFormat = "%d-%m-%Y %H:%i";
    dhx.i18n.setLocale();

    $$("scheduler").load("", "scheduler");
    $$('scheduler').$$('month').show();
    $$('scheduler').$$('buttons').setValue('month');

    $$("scheduler").$setSize(contentWidth, contentHeight - OFFSET_HEIGHT);

    $$("scheduler").$$("calendar").attachEvent("onAfterMonthChange", function (newDate, oldDate) {
        PageMethods.PopulateScheduler(SuccessPopulateScheduler, FailurePopulateScheduler);
    });

});
[/code]

Hi,

I have found a solution for my problem !!!

the problem was in date format of start_date and end_date when i used $$(“scheduler”).parse.

i used the format “yyyy-MM-dd hh:mm:ss” but it was necessary to use “dd-MM-yyyy hh:mm:ss”. I think, the date format is defined with -> dhx.i18n.fullDateFormat = “%d-%m-%Y %H:%i”; during the initialisation of scheduler.

:arrow_right: Thx for your help.