Scheduler checkLimitViolation won't work

Hello,

I’m trying to use the checkLimitViolation method but it doesn’t work.
I’ve added the dhtmlxscheduler_limit.js in my html page.

I got this error in Chrome Javascript console :

Uncaught TypeError: Object #<Object> has no method 'checkLimitViolation' 

How to get this to work?

Hi,
what version of the scheduler do you use?
You can check following example
scheduler/samples/03_extensions/25_advanced_limitation.html
‘checkLimitViolation’ works properly there

Hello and thank you for your answer,

I’m using the last version : 3.7 standard edition.
I didn’t found the function “checkLimitViolation” in the samples;

I used this code to block Saturdays and Sundays :

scheduler.addMarkedTimespan({ days: [0, 6], zones: "fullday", type: "dhx_time_block", css: "weekend_section" });

But if i create an event for Saturday programmatically with :

scheduler.addEvent(...);

The event is created but it shoudn’t.

I can check afterwards if the event can or cannot be created with this function :

scheduler.attachEvent("onLimitViolation", function (event_id, event_object) { scheduler.deleteEvent(event_id); alert("An event cannot be created here"); return false; });

But how can I check before the creation of the event?
Thanks in advance.

Hello,
i’ve just downloaded v3.7 package from the site, have added marked timespan and onLimitViolation handler as in your code abowe.
Everything works as expected, I can’t add event in blocked area neither programmatically nor by mouse actions.
The example is attached, am I missing something?
25_advanced_limitation.zip (1.58 KB)

Hello!

I tried your solution after downloading the Scheduler 3.7.
I cannot create an event with mouse actions (double click, drag move, …) on weekends but…
the event is created on saturday when i click on the button and an alert is shown :

 Event ... cannot be created here.

You’re right, I did not notice that event stays in blocked area after you close the alert.
Looks like currently you should check check limit violation manually before calling .addEvent

if(scheduler.checkLimitViolation(event_obj)){ scheduler.addEvent(event_obj); }
We’ll investigate the problem, probably fix will be included in next version of the scheduler. But for now .checkLimitViolation should be called manually before adding events programmatically

Hello,

Yes but that was my first problem, the method “checkLimitViolation” doesn’t work.
On my browser, it says that this method is undefined.

Do you have a sample that works?
I can’t find any…

Thanks.

Have you included on the page ext/dhtmlxscheduler_limit.js ?

Yes.

I’ve search everywhere and I didn’t find the checkLimitViolation function.

In case of dhtmlxscheduler, checkLimitViolation is defined in ext/dhtmlxscheduler_limit.js
If this file was included ( after dhtmlxscheduler.js ) - scheduler must have the method in question.

Hello Karim,
Were you able to solve this problem?

I have a similar issue where I want to prevent externalDragIn event (from tree control) to create event for a blocked time range. I tried to use checkLimitViolation but I get following error:

TypeError: scheduler.checkLimitViolation is not a function

I have included dhtmlxscheduler_limit.js file. I can block time span successfully. Only problem is with checkLimitViolation function.

I am using version 3.7 Standard.

Thanks,

Nasir