Okay, like the autopostback must be enabled to change the appointment color.
I will figure out the ajax issue.
Two questions may I discuss with you.
how to highlight the weekends or holidays on the calendar? I mean highlight the calendar background cells and bottom line(date) of the time lines if they are in weekend and holidays. Not the appointment.
It's not hard to check whether the date is or is not in weekend or holiday, but how about highlight them on the calendar?
Is that possible?
I have checked the help documentation, in the calendar control properties I didn't find any member like "CellColor" or "ColoumnColor".
Question two we have discussed a little bit before.
In case of calendar control autopostback is
enabled. At this moment as the snippet below shows, no matter I create new appointment or modify existing appointment, the corresponding appointment will have right color to display.
function itemCreating(sender, args)
{
var item = args.get_item();
switch (item.location)
{
case "1":
item.cssClass = 'Event1CssClass';
break;
case "2":
item.cssClass = 'Event2CssClass';
break;
case "3":
item.cssClass = 'Event3CssClass';
break;
case "4":
item.cssClass = 'Event4CssClass';
break;
}
}
function itemModifying(sender, args) {
if (args.get_changes().location) {
var loc = args.get_changes().location;
switch (loc) {
case "1":
sender.editItem(args.get_item(), { cssClass: "Event1CssClass" });
sender.editItem(args.get_item(), { location: "1" });
args.get_item().location = '1';
args.get_item().cssClass = 'Event1CssClass';
break;
case "2":
sender.editItem(args.get_item(), { cssClass: "Event2CssClass" });
sender.editItem(args.get_item(), { location: "2" });
args.get_item().location = '2';
args.get_item().cssClass = 'Event2CssClass';
break;
case "3":
sender.editItem(args.get_item(), { cssClass: "Event3CssClass" });
sender.editItem(args.get_item(), { location: "3" });
args.get_item().location = '3';
args.get_item().cssClass = 'Event3CssClass';
break;
case "4":
sender.editItem(args.get_item(), { cssClass: "Event4CssClass" });
sender.editItem(args.get_item(), { location: "4" });
args.get_item().location = '4';
args.get_item().cssClass = 'Event4CssClass';
break;
}
}
}
The code above works good which meet my goal, but every interaction will refresh the page, that's not an idea way.
In case of
disable the autopostback, I put same code for function "ItemCreated" and "ItemModified", or function "ItemCreating" and "ItemModifying", and of course added the scripts to calendar control.
The result was, not matter autopostback is on or off, "ItemCreating" works because it will assign right color to new created appointment. Then "ItemModifying" only work when autopostback is on.
So my understanding is if I want the color to be changed along with the location changing for existing appointment, I have to enable autopostback or do postback manually, is that right? Same with changing calendar Date and endDate.
Thank you!