We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Initializing ejRecurrenceEditor based on existing recurrence rule

I have the recurrence rule for the recurring appointments stored in a db, and I want the user to be able to edit the rule at a later date through the ejRecurrenceEditor.
The appointments are opened in a custom modal window when editing them in the Schedule.

My question is, how do you set the initial values of all the components in the ejRecurrenceEditor?
I want to be able to initialize the ejRecurrenceEditor based on simple and complex recurrence rules such as:
  • FREQ=WEEKLY;INTERVAL=2;BYDAY=MO
  • FREQ=YEARLY;BYDAY=FR;BYMONTH=5;BYSETPOS=3;INTERVAL=2;COUNT=10
In the following code snippet I would like to be able to 'apply' my recurrence rule to the recurrence editor, either when initilizing the ejRecurrenceEditor or when the create event is called.

$("#RecurrenceEditor").ejRecurrenceEditor({
            
            startDate: new Date(startDate),
            frequencies: ["daily", "weekly", "monthly", "yearly", "everyweekday"],
            selectedRecurrenceType: 0,
            locale: "da-DK",
            dateFormat: "yyyy-MM-dd",           
            create: function (args) {
                var ruleFromDB = "FREQ=WEEKLY;INTERVAL=2;BYDAY=MO";
                // set component based on above rule
            }
 });

4 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team May 13, 2019 02:25 AM

Hi Toke,    
 
Greetings from Syncfusion. 
 
Kindly use the below code example to achieve your requirement. 
 
$(function () { 
    $("#RecurrenceEditor").ejRecurrenceEditor({ 
        create: "onChange", 
    }); 
}); 
 
function onChange(args) { 
    var recurrenceObj = $("#RecurrenceEditor").data("ejRecurrenceEditor"); 
    var recurrenceRule = "FREQ=YEARLY;BYDAY=FR;BYMONTH=5;BYSETPOS=3;INTERVAL=2;COUNT=10"; 
    recurrenceObj.recurrenceRuleSplit(recurrenceRule); 
    recurrenceObj.showRecurrenceSummary(); 
} 
 
Regards, 
Karthi 



TW Toke Wivelsted May 13, 2019 05:22 AM

That was easier than expected, thank you for the swift response.


TW Toke Wivelsted May 13, 2019 08:09 AM

Worth noting (for anyone reading this at a later date) that the recurrence rule may not be an empty string. The following lines will result in a difficult to decipher error.

var recurrenceRule = "";
var recObj = $("#RecurrenceEditor").data("ejRecurrenceEditor");
recObj.recurrenceRuleSplit(recurrenceRule); 
recObj.showRecurrenceSummary();   
                


KK Karthigeyan Krishnamurthi Syncfusion Team May 13, 2019 11:13 PM

HI Toke. 
 
We are happy that our solution fulfilled your requirement. 
 
Assigning empty recurrence rule will render the recurrence editor like below. 
 
  
 
Regards, 
Karthi 


Loader.
Live Chat Icon For mobile
Up arrow icon