Accessing Custom Properties on AppointmentInsert Event

6 posts, 0 answers
  1. Bex
    Bex avatar
    53 posts
    Member since:
    Jul 2011

    Posted 29 Mar 2012 Link to this post

    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
  2. Bex
    Bex avatar
    53 posts
    Member since:
    Jul 2011

    Posted 29 Mar 2012 Link to this post

    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..

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 30 Mar 2012 Link to this post

    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.
  5. Maxim
    Maxim avatar
    1 posts
    Member since:
    Jul 2012

    Posted 04 Nov 2012 Link to this post

    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. 
  6. Bozhidar
    Admin
    Bozhidar avatar
    1101 posts

    Posted 07 Nov 2012 Link to this post

    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.
  7. Amit
    Amit avatar
    53 posts
    Member since:
    Aug 2012

    Posted 06 Jan 2014 Link to this post

    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 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017