Events not saving second update

Scenario: Events are not updating once they have been inserted/updated via ajax.

Reproduction Scenario 1: Create a new event, then update the event duration or date by dragging. Refresh the page and notice that the insert worked, but subsequent updates did not occur.

Reproduction Scenario 2: Create a new event, refresh the page. Update the event duration or date by dragging. Update the event duration or date again by dragging. Refresh the page and notice that only the first update was applied.

Possibly Related: viewtopic.php?f=25&t=29402&start=0&hilit=not+saving

Environment: Firefox / VS 2010 / ASP.NET MVC 4

What is occurring while debugging the back end (simply put) is the subsequent updates are not firing the configured custom save. Here is the source:

---- CSHTML -------------------------------------------------------------------------------------------
@{
Layout = “/Views/Shared/_Layout.cshtml”;
}

@Html.Raw(Model.Render())

---- Rendered View (abbrv) -----------------------------------------------------------------------

 
 
 
			</div><script>

scheduler.config.serverLists = {};scheduler.serverList(“sl_1_635077644160137899”, [{“key”:"#9fc6e7",“label”:“Meeting”},{“key”:"#7bd148",“label”:“Event”},{“key”:"#fbe983",“label”:“Personal”},{“key”:"#ffad46",“label”:“Follow up (Deadline)”}]);

scheduler.locale.labels.section_text = ‘Title’;
scheduler.locale.labels.section_description = ‘Description’;
scheduler.locale.labels.section_location = ‘Location’;
scheduler.locale.labels.section_color = ‘Event Type’;
scheduler.locale.labels.section_time = ‘Time’;
scheduler.config.lightbox.sections = [{“map_to”:“text”,“name”:“text”,“type”:“textarea”,“height”:40},
{“map_to”:“description”,“name”:“description”,“type”:“textarea”,“height”:80},
{“map_to”:“location”,“name”:“location”,“type”:“textarea”,“height”:60},
{“map_to”:“color”,“name”:“color”,“type”:“select”,“height”:30, “options”:scheduler.serverList(“sl_1_635077644160137899”)},
{“map_to”:“time”,“name”:“time”,“type”:“calendar_time”,“height”:30}];

scheduler.__show_minical = function(){
if (scheduler.isCalendarVisible())
scheduler.destroyCalendar();
else
scheduler.renderCalendar({“navigation”:true,
“date”:scheduler._date,
“position”:“schedulerdhx_minical_icon”,
“handler”:function(date,calendar){
scheduler.setCurrentView(date);
scheduler.destroyCalendar()
}
});
}
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.prevent_cache = true;
scheduler.config.server_utc = true;
scheduler.config.time_step = 30;
scheduler.config.multi_day = true;
scheduler.config.separate_short_events = true;
scheduler.config.hour_date = ‘%g:%i%a’;
scheduler.config.default_date = ‘%M %j, %Y’;
scheduler.config.scroll_hour = 13;
scheduler.init(‘scheduler_here’,new Date(2013,5,25));
dp = scheduler.dataProcessor = new dataProcessor("/Calendar/Save");
dp.init(scheduler);
dp.setTransactionMode(“POST”, false);
scheduler.load("/Calendar/LoadData", “json”);

— Controller / Actions ------------------------------------------------------------------------------

public ContentResult LoadData()
{
var data = new SchedulerAjaxData();
var models = GetLoggedInAgentCalendarEvents();

        data.Add(models);

        return new ContentResult {Content = data.ToString()};
    }

public ContentResult Save(int? id, FormCollection actionValues)
{
var action = new DataAction(actionValues);

        // Do NHibernate repository CRUD work according to values

        return new ContentResult {Content = new AjaxSaveResponse(action).ToString()};
    }

----- Final Observations ------------------------------------------------------------

Maybe completely unrelated but it appears that SchedulerAjaxData utilized a JSON data contract regardless of what you set the Scheduler object data format too; likewise, the AjaxSaveReponse renders XML regardless of data format. Maybe something there? As a hack, I tried to render the AjaxSaveReponse XML output as the JSON equivalent but that seemed to do nothing for me. Either way - I am guessing that it is the ContentResult on the return Save that is not correct for this default JSON Scheduler instance.

Any help is more than appreciated! Thanks in advance!

-squids

Any help on this from the product team? I can provide as much information as you would like and will in assist in fashion I can…

Thanks in advance,
-squids

Hello squids,
most probably client-side receives incorrect response from the first save action, and it prevents sending following ones.
Make sure that content type of the Save response is xml(scheduler uses xml for update/delete/insert confirmations for historical reasons)

btw, is there a reason why do you manually create ContentResult instance? return new ContentResult {Content = new AjaxSaveResponse(action).ToString()}; AjaxSaveResponse can be implicitly converted to ContentResult, and content type will be set automatically:public ContentResult Save(int? id, FormCollection actionValues){ ... return new AjaxSaveResponse(action);

Thank you very much, that did the trick.

Posting the answers here for reference:

I constructed the return result because I am using MVC4 and using the implicit operator fires code that would otherwise make be take a dependency on the System.Web.MVC v2 assembly.

public ContentResult Save(int? id, FormCollection actionValues)
        {
            var action = ProcessAction(id, actionValues);

            Response.ContentType = "application/xml";
            return new ContentResult {Content = new AjaxSaveResponse(action).ToString()};
        }

Hi,
thank you for the details. This bug should have been fixed some time ago and scheduler should work with any referenced version of MVC. I’ll check whether it’s occurs with the latest version of the component