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

Accessing Custom Properties on AppointmentInsert Event

5 Answers 200 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Bex
Top achievements
Rank 1
Bex asked on 29 Mar 2012, 08:41 AM
Hi

I have created my self a custom advanced insert form and added a checkbox list to it and a new dropdown list.

Then added 
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]

properties for each of these in the code behind that set them and get their values.
In my rad scheduler my custom insert template is added like so:

<AdvancedInsertTemplate>
   
        <uc1:ScheduleInsertEditor ID="ScheduleInsertEditor1" runat="server" Mode="Insert"
                        Subject='<%# Eval("Subject") %>'
                        Description='<%# Eval("Description") %>'
                        Start='<%# Eval("Start") %>'
                        End='<%# Eval("End") %>'
                        RecurrenceRuleText='<%# Eval("RecurrenceRule") %>'
                        Type='<%# Eval("Type")??0  %>'
                        Users='<%#GetUsers( Eval("Id")==null?0:int.Parse(Eval("AppointmentId").ToString() )) %>'
                       ></uc1:ScheduleInsertEditor>
    </AdvancedInsertTemplate>

The insert opens ok and what ever's passed in appears but in my AppointmentInsert  event I don't know how to get at these values to  add to the appointment.

Before I created the advanced form my insert was like so:
protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
      {
          //add the new appointment to the db
 
          int? recurrentParentId = null;
          if (e.Appointment.RecurrenceParentID != null) recurrentParentId = (int)e.Appointment.RecurrenceParentID;
           AppointmentManager.AddUserAppointment(
              UserId,
               int.Parse(e.Appointment.Resources[0].Key.ToString()),
              e.Appointment.Start,
              e.Appointment.End,
              e.Appointment.RecurrenceRule,
              recurrentParentId,
              e.Appointment.Description,
              e.Appointment.Subject);*/
          BindBindSchedule();
      }

Now I have added custom properties how do I get al them?
Should the be in the e.Appointment? They do not appear under resources or attributes.

My full radScheduler html is:

<telerik:RadScheduler runat="server"
        ID="SchToday"
        DayStartTime="08:00:00"
        DayEndTime="22:00:00"
        StartInsertingInAdvancedForm="true"
        ShowNavigationPane="true"
        OnAppointmentInsert="RadScheduler1_AppointmentInsert"
        OnAppointmentUpdate="RadScheduler1_AppointmentUpdate"
        OnAppointmentDelete="RadScheduler1_AppointmentDelete"
        DataKeyField="AppointmentId"
        DataStartField="Start"
        DataSubjectField="Subject"
        DataEndField="EndX"
        FirstDayOfWeek="Monday"
        ShowHeader="true"
        ShowFooter="false">
    <AdvancedForm Modal="true" />
    <DayView UserSelectable="true" />
    <WeekView UserSelectable="true" />
    <MonthView UserSelectable="true" />
    <DayView HeaderDateFormat="ddd dd MMMM yyyy" />
    <WeekView HeaderDateFormat="ddd dd MMMM yyyy" />
    <TimelineView HeaderDateFormat="ddd dd MMMM yyyy" />
    <MonthView HeaderDateFormat="MMMM yyyy" />
    <TimeSlotContextMenuSettings EnableDefault="true" />
    <AppointmentContextMenuSettings EnableDefault="true" />
    <AdvancedInsertTemplate>
   
        <uc1:ScheduleInsertEditor ID="ScheduleInsertEditor1" runat="server" Mode="Insert"
                        Subject='<%# Eval("Subject") %>'
                        Description='<%# Eval("Description") %>'
                        Start='<%# Eval("Start") %>'
                        End='<%# Eval("End") %>'
                        RecurrenceRuleText='<%# Eval("RecurrenceRule") %>'
                        Type='<%# Eval("Type")??0  %>'
                        Users='<%#GetUsers( Eval("Id")==null?0:int.Parse(Eval("AppointmentId").ToString() )) %>'
                       ></uc1:ScheduleInsertEditor>
    </AdvancedInsertTemplate>
    
    <AppointmentTemplate>
         <div>
            <h2>
                <%# Eval("Subject") %>
            </h2>
             
        </div>
    </AppointmentTemplate>
</telerik:RadScheduler>


Do I need to add something else?

Bex

5 Answers, 1 is accepted

Sort by
0
Bex
Top achievements
Rank 1
answered on 29 Mar 2012, 11:06 AM
Ok,I have found an easier way to do this (although would still like to know how to get it to work like above for future)
I have set resource:
<ResourceTypes>
       <telerik:ResourceType KeyField="ID" Name="Type" TextField="Keyword" ForeignKeyField="AppointmentTypeID"
           DataSourceID="AppointmentTypesDataSource" />
   </ResourceTypes>

I did not realise you could have multivalues with resources.

I set my users in the code behind like so:
UserDetailCollection allUSers = UserManager.GetAssociatedUsers(currentUserId());
          ResourceType users = new ResourceType("Added Users");
 
          users.AllowMultipleValues = true;
          users.ForeignKeyField = "AppointmentId";
          SchToday.ResourceTypes.Add(users);
 
 
          foreach (UserDetail user in allUSers)
          {
              SchToday.Resources.Add(new Resource("Added Users", user.UserId, user.FullName));
          }

I would like it to be more custom, but this works for now.. 
I am now just having trouble rebinding the selected users to the list when I edit the appointment...
When I save an appointment they userIds are going into a userAppointment Table.
When I bind my schedule I am doing it in the code behind using schToday.datasource=....
My Table is set up exactly how the documentation says, but it doesn't say how to reference another table that contains multi values..

0
Ivana
Telerik team
answered on 30 Mar 2012, 01:08 PM
Hi Becky,

Take a look at the following Code Library:Customize the Advanced Form with the Advanced Template User Controls.  It shows how to customize the advanced form using the advanced template user controls with RadScheduler bound to various data sources.

Kind regards,
Ivana
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.
0
Maxim
Top achievements
Rank 1
answered on 04 Nov 2012, 04:49 PM
I agree , there is bug with RadScheduler1_AppointmentInsert. The resources collection is not passed, while down 
the code execution in sqlsource_Inserting gets the right resource id. It would be nice to get resources passed in AppointmentInsert event too. 

PS i use a custom inlineinsert template and may be it makes a difference for the bug. 
0
Bozhidar
Telerik team
answered on 07 Nov 2012, 11:00 AM
Hello Maxim,

I can't seem to reproduce the issue. The resource collection does get passed in the AppointmentInsert event, it's just that it's empty, because the InlineInsert form doesn't contain logic for modifying the appointment's resources. Customizing the form it in a way to support resource editing is a custom solution and is not supported out of the box by RadScheduler.
 
Kind regards,
Bozhidar
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.
0
Amit
Top achievements
Rank 1
answered on 06 Jan 2014, 06:35 AM
Hi bex can you please share your code project for my reference ,
I am also using the radshedular but there are lots of issues so can you please give your code or running sample project so it will be little helpful

Thanks and Regard,
Amit 
Tags
Scheduler
Asked by
Bex
Top achievements
Rank 1
Answers by
Bex
Top achievements
Rank 1
Ivana
Telerik team
Maxim
Top achievements
Rank 1
Bozhidar
Telerik team
Amit
Top achievements
Rank 1
Share this question
or