Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get the recurrence string from a KendoUI Recurrence Editor?

Because I needed a custom setup for my scheduling setup, I am implementing separate Calendar, Scheduler, and RecurrenceEditor widgets. So far, everything has worked fine, but I can't get the parsed string from the RecurrenceEditor widget. I haven't seen a method to pull the rule as a string in the API documentation (nor is the RecurrenceEditor widget really documented there).

This is how I'm setting up the recurrenceEditor:

$(document).ready(function()
{
  $("#recurrence-editor").kendoRecurrenceEditor({
    start: new Date(),
    change: function(e)
    {
      var editor = e.sender;

      // I want to get the recurrence rule string here.
    }
  });
});

I'm not seeing anything in Firebug that gives me a hint for the method or property I might try. So far, I've tried:

editor.ruleValue
editor.recurrenceRule

It looks like I have access to some of the information, but I didn't want to write my own selections-to-parseable-string method if I could get it from the recurrence editor itself.

UPDATE: When I set it up this way:

$(document).ready(function()
{
  $("#recurrence-editor").kendoRecurrenceEditor({
    start: new Date(),
    edit: function(e)
    {
      var editor = e.sender;
      var recurrenceString = editor.RecurrenceRule;

      return recurrenceString;
    }
  });
});

The edit event never fires. Probably because I'm not implementing the recurrence editor as part of the Scheduler widget, but as a standalone widget on the page.

Thanks!

like image 405
Peter Adams Avatar asked Dec 11 '25 10:12

Peter Adams


1 Answers

Setup the recurrence editor in the Scheduler's edit event, it will fire the change event and the value property is the standard iCal Recurrence Rule.

Here's mine:

// Setup Recurrence Editor
// Telerik support recommends this method over the common inline script
// because it allows us to choose which recurrence editor.  However, it does
// break the MVVM two-way bindings, so the current value MUST be explicitly set
// on creation, and the change event must be handled.
var event = e.event,
    container = e.container,
    recurrenceEditor = container.find("#recurrenceEditor");

if (kendo.support.mobileOS === false) {
    recurrenceEditor.kendoRecurrenceEditor({
        start: new Date(e.event.start),
        value: e.event.recurrenceRule,
        timezone: self.scheduleConfig.timezone,
        messages: self.scheduleConfig.messages.recurrenceEditor,
        change: function (ev) {
            event.set("recurrenceRule", this.value());
        }
    });
} else {
    // The Mobile Recurrence Editor requires the parent kendo pane
    // be passed as a parameter, otherwise it will crash when the
    // user attempts to alter the frequency

    var pane = container.parent(".km-pane").data("kendoMobilePane");

    recurrenceEditor.kendoMobileRecurrenceEditor({
        start: new Date(e.event.start),
        value: e.event.recurrenceRule,
        timezone: self.scheduleConfig.timezone,
        messages: self.scheduleConfig.messages.recurrenceEditor,
        pane: pane,
        change: function(ev) {
            event.set("recurrenceRule", this.value());
        }
    });
}

And the HTML (inside the custom editor template)

 <div class="lineEntry" data-bind="invisible: recurrenceId">
    <div id="recurrenceEditor" name="recurrenceRule" data-bind="value: recurrenceRule" class="toInlineBlock">
    </div>
 </div>
like image 191
AUSTX_RJL Avatar answered Dec 15 '25 16:12

AUSTX_RJL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!