Hi, I am using dhtmlx open source version of scheduler. The issue is that if I return action_type=“error”, the scheduler still goes on and displays the event on the screen, when infact there is no database entry related to it (I am returning action_type=“error” for database related errors). I am pasting the code that I am using for the scheduler. Its based on asp.net MVC.
The scheduler.html
[code]@section scripts {
}
<div id="ns-calendar">
<div id="scheduler_here" class="dhx_cal_container" >
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button"> </div>
<div class="dhx_cal_next_button"> </div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
</div>
<div class="dhx_cal_header">
</div>
<div class="dhx_cal_data" >
</div>
</div>
</div>
[/code]
The Controller with Data (load) and Save(update) method
[code] public XmlResult Data() {
return new XmlResult();
}
public XmlEditResult Save(FormCollection actionValues) {
String action_type = actionValues["!nativeeditor_status"];
long source_id = long.Parse(actionValues["id"]);
long target_id = source_id;
DHTML_SchedulerDataContext data = new DHTML_SchedulerDataContext();
Event myevent;
try {
switch (action_type) {
case "inserted":
myevent = new Event();
myevent.start_date = DateTime.Parse(actionValues["start_date"]);
myevent.end_date = DateTime.Parse(actionValues["end_date"]);
myevent.text = actionValues["text"];
data.Events.InsertOnSubmit(myevent);
break;
case "deleted":
myevent = data.Events.SingleOrDefault(ev => ev.id == source_id);
data.Events.DeleteOnSubmit(myevent);
break;
default: // "updated"
myevent = data.Events.SingleOrDefault(ev => ev.id == source_id);
myevent.start_date = DateTime.Parse(actionValues["start_date"]);
myevent.end_date = DateTime.Parse(actionValues["end_date"]);
myevent.text = actionValues["text"];
break;
}
data.SubmitChanges();
target_id = myevent.id;
}
catch {
action_type = "error";
}
return new XmlEditResult(new CalendarEditResponseModel(action_type, source_id, target_id));
}
[/code]
The ActionResult for returning xml response.
public override void ExecuteResult(ControllerContext context) {
HttpResponseBase response = context.HttpContext.Response;
response.ContentType = "text/xml";
response.Write("<data>");
response.Write("<action type=" + model.Status +
" sid=" + model.Source_id +
" tid=" + model.Target_id + "></action>");
response.Write("</data>");
}
The model
public class CalendarActionResponseModel {
public String Status;
public long Source_id;
public long Target_id;
public CalendarActionResponseModel(String status, long source_id, long target_id) {
Status = status;
Source_id = source_id;
Target_id = target_id;
}
}
I would be very grateful if anyone can please help me resolve this issue.
regards,
Nirvan