Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Retrieving of the data should be the same as for simple events, except that you'll render 3 extra fields - event_length, event_pid, rec_type. The default value of rec_type(which will mean that event is not recurring) is empty string of null</p> <p>As for saving, check "Controller changes" paragraph of this article, it might help <a href="http://scheduler-net.com/docs/recurring_events.html#controller_changes" rel="nofollow">http://scheduler-net.com/docs/recurring_events.html#controller_changes</a></p> <p>Although it targets dhtmlxScheduler for .Net, which is separate component, the processing logic is the same.</p> <p>In general, saving of recurring events will work the same way as for simple ones(the same method could process simple and recurring events), but you'll need to add additional logic for the following cases:</p> <ol> <li>if an event with (<strong>rec_type == "none"</strong>) was inserted - the response must have "deleted" status; </li> <li>if an event with (<strong>!string.IsNullOrEmpty(rec_type) &amp;&amp; rec_type != "none"</strong>) was updated or deleted - all records with the related event_pid must be deleted;</li> <li>if an event with non-default <strong>event_pid</strong> value was deleted - it need to be updated with <strong>rec_type = "none"</strong> instead of deleting.</li> </ol> <p><strong>UPD</strong>, Code Sample</p> <p>The final code might look like following(I didn't actually run it, so it may contain some mistakes), </p> <p>All changes, compared to simple version, is the "deleteRelated" method(note that if deleteRelated returns true, switch-case should be omitted) and checking of the Rec_Type in the "inserted" case</p> <pre><code>public ActionResult Save(Event changedEvent, FormCollection actionValues){ String action_type = actionValues["!nativeeditor_status"]; Int64 source_id = Int64.Parse(actionValues["id"]); Int64 target_id = source_id; string category = actionValues["category"]; string title = actionValues["title"]; string description = actionValues["text"]; if (!string.IsNullOrEmpty(actionValues["rec_type"])) changedEvent.Rec_Type = actionValues["rec_type"]; if (!string.IsNullOrEmpty(actionValues["event_length"])) changedEvent.Event_Length = Convert.ToInt32(actionValues["event_length"]); if (!string.IsNullOrEmpty(actionValues["event_pid"])) changedEvent.Event_Pid = Convert.ToInt16(actionValues["event_pid"]); String catg = category; changedEvent.UserId = 1; changedEvent.Category = catg; changedEvent.Description = description; changedEvent.Title = title; try { if (!deleteRelated(action_type, changedEvent, db))//some logic specific for recurring events { switch (action_type) { case "inserted": changedEvent.UserId = 1; changedEvent.Category = catg; db.Events.AddObject(changedEvent); if (changedEvent.Rec_Type == "none") action_type = "deleted";//if an event with (rec_type == "none") was inserted - the response must have "deleted" status break; case "deleted": changedEvent = db.Events.SingleOrDefault(ev =&gt; ev.Id == source_id); db.Events.DeleteObject(changedEvent); break; default: // "updated" db.Events.Attach(changedEvent); db.ObjectStateManager.ChangeObjectState(changedEvent, System.Data.EntityState.Modified); db.SaveChanges(); break; } } db.SaveChanges(); target_id = changedEvent.Id; } catch { action_type = "error"; } return View(new CalendarActionResponseModel(action_type, source_id, target_id, catg)); } protected bool deleteRelated(string action_type, Event changedEvent, RecurringEntities db)// { bool finished = false; if ((action_type == "deleted" || action_type == "updated") &amp;&amp; !string.IsNullOrEmpty(changedEvent.Rec_Type)) { //if an event with (!string.IsNullOrEmpty(rec_type) &amp;&amp; rec_type != "none") was updated or deleted - all records with the related event_pid must be deleted; db.ExecuteStoreCommand("DELETE FROM Films WHERE Event_Pid = {0}", changedEvent.Id); } if (action_type == "deleted" &amp;&amp; (changedEvent.Event_Pid != 0 &amp;&amp; changedEvent.Event_Pid != default&lt;Int16&gt;)) { //if an event with non-default event_pid value was deleted - it need to be updated with rec_type = "none" instead of deleting. var item = db.Events.SingleOrDefault(ev =&gt; ev.Id == changedEvent.Id); item.Rec_Type = "none"; db.SaveChanges(); finished = true; //in this case no more processing is needed } return finished; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload