Readonly at load won't work

I’m loading events via XML and I’m setting the readonly attribute to 0 or 1 but the scheduler doesn’t seem to honor the readonly flag. Do I need to take som action after data loading, like looping through events and setting a flag?

XML example (I’m building the XML manually via C# and SQL Server based on your MVC tutorial):

<event id="@Convert.ToInt32(dataRow["eventID"].ToString())"> <start_date><![CDATA[@String.Format("{0:MM/dd/yyyy HH:mm}", Convert.ToDateTime(dataRow["startDate"]))]]></start_date> <end_date><![CDATA[@String.Format("{0:MM/dd/yyyy HH:mm}", Convert.ToDateTime(dataRow["endDate"]))]]></end_date> <text><![CDATA[@Html.Encode(dataRow["text"].ToString())]]></text> <readonly><![CDATA[@dataRow["readonly"].ToString()]]></readonly> </event>

It returns 0 and 1 on ev.readonly, see attached image, but I can still move around and edit events that have readonly=1. Any ideas?

By default scheduler doesn’t recognize readonly attribute, be sure to include

ext/dhtmlxscheduler_readonly.js

also, to work correctly you may need to use

readonly=""

instead of

readonly=“0”

Thanx, now it worked better but I have one problem left. The form is readonly but I can still move around events (and thus change date) even if they are marked as readonly.

Should I loop or perform an action on onBeforeDrag event or something to sovle this?

Great product btw. FYI I had to use readonly = “” and readonly = 1.

you can add check through onBeforeDrag and return false for events which has readonly attribute ( returning false will block dnd operations )

Thanx.

The below code performs that but I end up with a strange thing on drag-create of new events (which I want to allow).

scheduler.attachEvent("onBeforeDrag", check_readonly); function check_readonly(id) { var ev = scheduler.getEvent(id); if (ev.readonly == true) { return false; //dissalow drag-move on this event } else { return true; } }
1.
When I drag-create a new event I never get the form popup. Instead the eventbar follows my mousepointer even after I let the mousebutton go.

If I remove the code above, I can drag-create events as normal.

If I on the other hand have moved an object just once, then drag-create works for new events.

But any time on first load, the drag-create doesn’t work.

I had to do a id == null check first to get this to work on new events. Below works.

scheduler.attachEvent("onBeforeDrag", check_readonly); function check_readonly(id) { if (id == null) { //true for new events on first site visit return true; } else { //check readonly flag var ev = scheduler.getEvent(id); if (ev.readonly == true) { return false; //disallow drag-move on this event } else { return true; //allow drag-move } } }