Scheduler.clearAll() calls url associated with .Load(url)

Hi,
When the page first loads I call:

function LoadScheduler(parameterID) {
        $$("scheduler").load("url?parameter=" + parameterID.toString(), "json", {
            error: function (text, xml, XmlHttpRequest) {
                alert("Error with Scheduler: " + text);
            }
        });
}

^^This works perfectly.

I then have a select input on my page. When I change the select input value I want to load new data into the scheduler. I tried doing this with the following code:

    $(function () {
        $("#select").change(function () {
            if ($("#select").val()) {  
                var parameterID = $("#select").val();

                $$("scheduler").clearAll();
                //LoadScheduler(parameterID);
            }
        });
    });

As you can see I commented out the LoadScheduler() function. This is because I was trying to isolate the problem. When $$(“scheduler”).clearAll(); gets fired, it triggers the original url with the original parameters that were in the .load(url + parameters). It does successfully clear the events in the schedule, though. Why does it call my original url?

I want to load new data into my schedule when a new value is selected from my select input. Scheduler.clearAll() seems to interfere.

Thanks,
Dan

By any chance do you have dynamic loading enabled for the scheduler in question?

I don’t believe I have dynamic loading enabled. I have a ticket open for this, but just in case I’ll share with you my initialization code. If you’d rather it be solved in a ticket I can post the answer here when I’m done.

     scheduler.config.readonly = true;
    scheduler.config.header_date = "%D, %M %j %Y";
    scheduler.config.scale_hour = "%h %i %a";
    scheduler.config.hour_date = "%h:%i %A";
    scheduler.config.item_date = "%m.%j.%Y";
    scheduler.config.show_loading = true;

    dhx.ready(function () {
        dhx.ui.fullScreen();
        dhx.ui({
            container: "schedulerDiv",
            view: "scheduler",
            id: "scheduler"
        });

        $$("scheduler").setLoadMode("month");
        SetDefaultClinic();
});

    function SetDefaultParameter() {
        var selectedParamId = "@ViewBag.ParamID";
        if (!selectedParamId) {
            selectedParamId= $("#select option:first").val();
        }
        $("#select").val(selectedParamId);
        LoadScheduler(selectedParamId);
    }

    function LoadScheduler(selectedParamId) {

        $$("scheduler").load("/PTAnywhereClient/Schedule/GetAppointments?ParamId=" + selectedParamId.toString(), "json", {
            error: function (text, xml, XmlHttpRequest) {
                alert("Error with Scheduler: " + text);
            }
        });
    }

Alexandra Klenova solved the problem for me in a ticket I submitted.

The problem was that .clearAll() doesn’t just clear the scheduler, it also refreshes the scheduler. This causes it to call the method that returns my data again. The solution is to clear the scheduler without having it refresh the scheduler. Here is the code to do this:

$$("scheduler").data.silent(function(){
this.clearAll();
});

I put this code just above scheduler.load() in my LoadScheduler() function.
Problem solved.

Thank you guys very much!

I had a smilar issue, I added

$$("scheduler").data.silent(function(){ this.clearAll(); });
But it is giving a js error

I have my dhtmlxscheduler.js included.

Jaoude,

could you attach the sample that reproduces the problem ?

Hello,
What exactly is the answer to this? I don’t understand what “$$” means.
If i call
scheduler.data.silent(function(){
this.clearAll();
});
I get : Cannot read property ‘silent’ of undefined…as expected.
So, how can i call “clearAll” without calling my default data. i already have a client side object ready to be used with "scheduler.parse(new_events,‘json’);

    scheduler.clearAll();
    scheduler.parse(new_events, 'json');

This code populates as expected for a split second (before my default “data” url is called).

I am using “dynamic loading”.
Thank you!