Add description text to DayView

2 posts, 1 answers
  1. Allan
    Allan avatar
    3 posts
    Member since:
    Aug 2012

    Posted 12 Sep 2012 Link to this post

    I would like to know if it is possible to add the description inside an appointment block that is in a DayView State?

    When I click on an appointment I see the description in the Advance Edit Form...
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Sep 2012 Link to this post

    Hi Allan,

    I suppose you want to add description in the appointment of RadScheduler in the DayView only. One suggestion is that you can add an AppointmentTemplate in aspx will be overridden from code-behind. Following is the sample code that I tried based on your scenario.

    ASPX:
    <AppointmentTemplate>
        <asp:Literal ID="AppointmentSubject" runat="server" Text='<%# Eval("Subject") %>'></asp:Literal>
        <asp:Literal ID="AppointmentDescription" runat="server" Text='<%# Eval("Description") %>'></asp:Literal>
    </AppointmentTemplate>

    C#:
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (RadScheduler1.SelectedView != SchedulerViewType.DayView)
                {
                    RadScheduler1.AppointmentTemplate = new AppTemplate();
                }
            }
        }
    public class AppTemplate : ITemplate
        {
            public void InstantiateIn(Control container)
            {
                Literal subject = new Literal();
                subject.DataBinding += subject_DataBinding;
                container.Controls.Add(subject);
            }
     
            private void subject_DataBinding(object sender, EventArgs e)
            {
                
                Literal subject = (Literal)sender;
                IDataItemContainer aptContainer = (IDataItemContainer)subject.BindingContainer;
     
                //Access the appointment object and set its AllowEdit property:
                SchedulerAppointmentContainer aptCont = (SchedulerAppointmentContainer)subject.Parent;
                Appointment app = aptCont.Appointment;
                app.AllowEdit = false;
     
                string strSubject = HttpUtility.HtmlEncode((string)DataBinder.Eval(aptContainer.DataItem, "Subject"));
                subject.Text = strSubject;
            }
        }
    protected void RadScheduler1_NavigationComplete(object sender, Telerik.Web.UI.SchedulerNavigationCompleteEventArgs e)
        {
            if (e.Command != SchedulerNavigationCommand.SwitchToDayView)
            {
                RadScheduler1.AppointmentTemplate = new AppTemplate();
            }
        }

    Please take a look into this for more information.

    Hope this helps.

    Regards,
    Shinu.
Back to Top