search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

I am trying to delete a series of events using recurrence rule.. Is there a sample implementation available?

Asked by Dave Periam
9 years ago.

I have looked at the Tutorial Shift Scheduler application which has not helped...

I am using DayPilot Version: 8.1.3469.1..

I am using DayPilotMenuItem to "Delete a series" of recurring events..

I would like to use the call back implementation.

Is there a simple sample implementation available to delete a series of events using the recurrence rule from a database with DayPilot Scheduler?

Please advise, thanks & regards

Dave aka mrplatypus

Answer posted by Dan Letecky [DayPilot]
9 years ago.

You can read the ID of the master event (that one that defines the series) using e.RecurrentMasterId. If you don't define any exception from the rule just delete the record with this ID.

    protected void DayPilotScheduler1_EventMenuClick(object sender, DayPilot.Web.Ui.Events.EventMenuClickEventArgs e)
    {
        switch (e.Command)
        {
            case "DeleteSeries":
                Db.DeleteEvent(e.RecurrentMasterId);
                break;
        }

        setDataSourceAndBind();
        DayPilotScheduler1.Update();
    }

Replace Db.DeleteEvent() with your own data access layer implementation.

If you allow users to define exceptions from the rule (e.g. this week the meeting starts at 3pm instead of 4pm as defined in the master) then you might want to delete these exceptions as well (each exception has its own record in the database).

If you don't store the master id with the exception record you can find these records using the recurrence field (DataRecurrenceField): All exceptions related to the same master event will use the recurrence field that starts with a prefix derived from the master ID:

string prefix = RecurrenceRule.Prefix(e.RecurrenceMasterId);

Then you simple delete all records where the DataRecurrenceField starts with this prefix. Something like this:

DayPilotScheduler1.DataRecurrenceField="recurrence_info";  // you store the recurrence string in "recurrence_info" db field

...

string prefix = RecurrenceRule.Prefix(e.RecurrenceMasterId);
string cmd = "DELETE FROM events WHERE recurrence_info LIKE '" + prefix "%'";
// ...
Comment posted by Dan Letecky [DayPilot]
9 years ago.

Note: I'm removing the "lite" tag as this question is about the Pro version.

Comment posted by Dave Periam
9 years ago.

Dan,

Thanks for your reply this has helped me perfectly.

On a side note, I am allowing the users to delete an item mid-flow from the recurrence..

For example:

Say a user makes a recurring appointment on a Monday every day (Monday through Friday) at 13:00..
The user then chooses to delete or cancel the Tuesday appointment - how does DayPilot deal with that? Does DayPilot deal with it? If not, what would be your recommendations?

Please advise.

Thanks

Dave (aka mrplatypus)

Comment posted by Dan Letecky [DayPilot]
9 years ago.

Yes, DayPilot supports this - you can add a new item to the event list that will tell DayPilot that a specific occurrence should be modified or removed. This is called a "recurrence exception".

You need to create a new record add set the recurrence file to special value generated by one of the following methods:

  • RecurrenceRule.EncodeExceptionModified()
  • RecurrenceRuleEncodeExceptionDeleted()

See also the "Recurring Events" topic in the documentation - a section called "Creating an exception from the rule":
http://doc.daypilot.org/scheduler/recurring-events/

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.