Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Custom appointment scheduling in RadScheduler

$
0
0
Hello Abhishek,

Thank you for writing back.
 
As noted in my previous post, you can create a custom AppointmentElementin order to display any custom data. It is necessary to override the AppointmentElement.CreateAppointmentText method and return the desired string information. Here is a sample code snippet demonstrating how  to create a custom AppointmentElement and replace the default one in the SchedulerElementProvider:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        this.radScheduler1.ElementProvider = new MyElementProvider(this.radScheduler1);
        for (int i = 0; i < 3; i++)
        {
            AppointmentExtended a = new AppointmentExtended();
            a.FName = "FName" + i;
            a.LName = "LName" + i;
            a.Contact = "Contact" + i;
            a.Start = DateTime.Now.AddDays(i);
            a.Duration = TimeSpan.FromHours(2);
            a.Summary = "Meeting" + i;
            a.Location = "Location" + i;
            this.radScheduler1.Appointments.Add(a);
        }
    }
 
    public class CustomAppointmentElement : AppointmentElement
    {
        public CustomAppointmentElement(RadScheduler scheduler, SchedulerView view, IEvent appointment) : base(scheduler, view, appointment)
        {
        }
 
        protected override string CreateAppointmentText()
        {
            AppointmentExtended a = this.Appointment as AppointmentExtended;
            if (a != null)
            {
                //return the desired information
                return a.FName + " " + a.LName + ", " + a.Contact;
            }
            return null;
        }
    }
 
    public class MyElementProvider : SchedulerElementProvider
    {
        public MyElementProvider(RadScheduler scheduler) : base(scheduler)
        {
        }
 
        protected override T CreateElement<T>(SchedulerView view, object context)
        {
            if (typeof(T) == typeof(AppointmentElement))
            {
                return new CustomAppointmentElement(this.Scheduler, view, (IEvent)context)as T;
            }
            
            return base.CreateElement<T>(view, context);
        }
    }
}
 
public class AppointmentExtended : Appointment
{
    string _appID = string.Empty;
    string _patientID = string.Empty;
    string _fName = string.Empty;
    string _lName = string.Empty;
    string _medAidID = string.Empty;
    string _contact = string.Empty;
    string _fees = string.Empty;
 
    public AppointmentExtended() : base()
    {
    }
 
    public string AppID
    {
        get
        {
            return _patientID;
        }
        set
        {
            if (_appID != value)
            {
                _appID = value;
                this.OnPropertyChanged("AppID");
            }
        }
    }
 
    public string PatientID
    {
        get
        {
            return _patientID;
        }
        set
        {
            if (_patientID != value)
            {
                _patientID = value;
                this.OnPropertyChanged("PatientID");
            }
        }
    }
 
    public string FName
    {
        get
        {
            return _fName;
        }
        set
        {
            if (_fName != value)
            {
                _fName = value;
                this.OnPropertyChanged("FName");
            }
        }
    }
 
    public string LName
    {
        get
        {
            return _lName;
        }
        set
        {
            if (_lName != value)
            {
                _lName = value;
                this.OnPropertyChanged("LName");
            }
        }
    }
 
    public string MedAidID
    {
        get
        {
            return _medAidID;
        }
        set
        {
            if (_medAidID != value)
            {
                _medAidID = value;
                this.OnPropertyChanged("MedAidID");
            }
        }
    }
 
    public string Contact
    {
        get
        {
            return _contact;
        }
        set
        {
            if (_contact != value)
            {
                _contact = value;
                this.OnPropertyChanged("Contact");
            }
        }
    }
}​

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>