Delete/insert events in a single click using custom lightbox

Hello,

In my scheduler I need to add functionality that removes all events with the same name. User should be able to do this by dbl-cklicking one of those events and clicking a button in a custom lightbox.

Than all those events will be deleted and a new one created and inserted in to scheduler.

Now my question is what should be the return from CustomSave action method for the scheduler to update properly ?

It’s pretty standard when one event is inserted/deleted/updated but what if this should be done on multiple events with one call to CustomSave?

[code]public ActionResult CustomSave(CalendarEvent changedEvent, FormCollection actionValues)
{

        var action = new DataAction(DataActionTypes.Update, changedEvent.id, changedEvent.id);

        if (actionValues["actionButton"] != null)
        {
            try
            {
                 if (actionValues["actionButton"] == "DeleteAndInsert")
                {
                    //delete all events where name ='...'
                    _repositoryEvents.Delete(changedEvent.Name);

                    //create a new event
                    //.... some code

                     //Insert new event to dataBase
                    _repositoryEvents.Insert(newEvent);
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
        }
        else
        {
            action.Type = DataActionTypes.Error;
        }
        //! what to return here ?
        return (new SchedulerFormResponseScript(action, changedEvent));

    }[/code]

Hi,
probably the easiest way would be to return some flag in the ‘action’ object, and if such flag is detected in server response - simply reload the scheduler events
C#:[code]action.Message = “reload”;

return (new SchedulerFormResponseScript(action, changedEvent));[/code]

JS:scheduler.dataProcessor.attachEvent("onAfterUpdate", function(sid, status, tid, action){ if(tag.textContent == "reload"){ scheduler.clearAll(); scheduler.load(url); } return false; });

Thanks! this works great :slight_smile:

Only it should be

if (action.textContent == "reload") { refresh(); }

there is no tag variable :slight_smile: