This is a migrated thread and some comments may be shown as answers.

Binding recurrence rule from client side

1 Answer 144 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Mahesh
Top achievements
Rank 1
Mahesh asked on 19 Sep 2012, 12:10 PM

Hi,

  we are trying to bind the recurrence rule from javascript.

Upon saving , we are taking the recurrence rule from javascript and saving it to database. On taking the recurrence rule it is shown as "DTSTART:20120927T000000Z  DTEND:20120927T000000Z  RRULE:FREQ=WEEKLY;UNTIL=20120928T000000Z;INTERVAL=1;BYDAY=WE,SU;WKST=".
We are saving this value in db.

After that on the client form created we are taking the appointment details corresponding to this appointment id using one service call and we are getting the values in javascript.

After that we are trying to bind this value to controls.

So for binding recurrence rule we are using the below given code.

var rrule = Telerik.Web.UI.RecurrenceRule.parse(apt1.get_recurrenceRule());    
var editor = $find("<%=AppointmentRecurrenceEditor.ClientID%>");
editor.set_recurrenceRule(rrule);
 Here recurrence is not binding when we alerted the value of "rrule" it is shown as "null"

After that we tried like setting the rule as such in set method like

var editor = $find("<%=AppointmentRecurrenceEditor.ClientID%>");
editor.set_recurrenceRule("DTSTART:20120927T000000Z  DTEND:20120927T000000Z  RRULE:FREQ=WEEKLY;UNTIL=20120928T000000Z;INTERVAL=1;BYDAY=WE,SU;WKST=");

In this case we are getting an error like "TypeError: i.get_pattern is not a function".

Please advice us on how to proceed in this case..


Thanks.


1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 24 Sep 2012, 12:01 PM
Hello Mahesh,

The problem that you have with your first approach is
  • Accessing a recurrence rule from appointment object is possible only when web services used.
  • Here you can find more information about client side appointment object and its methods.
In case of using a string object to represent a recurrence rule I will suggest to use "\n" symbol instead of " "
space(empty string). Example below shows recommended syntax for recurrence rule that will be parsed without any errors:
//aspx file

<telerik:RadScheduler runat="server" ID="RadScheduler1"
        OnClientFormCreated="OnClientFormCreated"
       ........................
    </telerik:RadScheduler>

//JavaScript

function OnClientFormCreated(sender, eventArgs) {
            var $ = $telerik.$;
            var mode = eventArgs.get_mode();
            if (mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert ||
                    mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) {
                var editorjQueryObject = $("[id$='RecurrenceEditor']");
                var editor = $find(editorjQueryObject.attr("id"));
 
                var stringRule = "DTSTART:20120927T000000Z\nDTEND:20120927T000000Z\nRRULE:FREQ=WEEKLY;UNTIL=20120928T000000Z;INTERVAL=2;BYDAY=WE,SU;";
                var rrule = Telerik.Web.UI.RecurrenceRule.parse(stringRule);
                 
                editor.set_recurrenceRule(rrule);
            }
        }

I hope this was helpful.


Greetings,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Mahesh
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or