Hi,
I just began experimenting with dhtmlxScheduler and was trying to set specific events to read-only. I have a “user” field I’ve added for each event in mysql and I want users to only be able to edit/delete the events that have their id in the user field. Whenever I try to add the following snippet of code (I have an event_id of 7 in my table):
scheduler.getEvent(7).readonly = true;
the page stops rendering.
Here is my more complete code:
<script type="text/javascript" charset="utf-8">
function init() {
var locations = [
<?php
include("mysql.php");
connect_to_database();
$result = mysql_query("select * from locations order by city asc;");
for ($i=0 ; $i<mysql_num_rows($result)-1; $i++) {
echo "{ key: ".mysql_result($result,$i,"id").", label: \"".
mysql_result($result,$i,"name_long")."\" },";
}
echo "{ key: ".mysql_result($result,$i,"id").", label: \"".
mysql_result($result,$i,"name_long")."\" }";
?>
];
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.prevent_cache = true;
scheduler.config.lightbox.sections=[
{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
{name:"location", options: locations, map_to:"location", type:"select",
image_path: "../../../dhtmlxcombo/codebase/imgs/", cache:false },
{name:"time", height:72, type:"time", map_to:"auto"}
]
scheduler.config.first_hour=4;
scheduler.locale.labels.section_location="Location";
scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;
scheduler.config.start_on_monday=false;
scheduler.config.hour_date="%h:%i %A";
<?php
if ($_GET["user"] == -1) { // <-- works great (-1 signifies "public user/unregistered")
echo "scheduler.config.readonly_form = true;";
}
//echo "scheduler.getEvent(7).readonly = true;"; <-- this is the troublesome line
?>
scheduler.init('scheduler_here',new Date(<?php echo date("Y,m-1,d"); ?>),"month");
scheduler.setLoadMode("month")
scheduler.load("php/events.php?user=<?php echo $_GET["user"]; ?>");
var dp = new dataProcessor("php/events.php?user=<?php echo $_GET["user"]; ?>");
dp.init(scheduler);
}
</script>