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

Add description text to DayView

1 Answer 61 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 1
Allan asked on 12 Sep 2012, 11:04 PM
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...

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 13 Sep 2012, 05:29 AM
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.
Tags
Scheduler
Asked by
Allan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or