Custom Data Binding

2 posts, 1 answers
  1. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 24 Dec 2010 Link to this post

    I'd like a run down regarding custom data binding scenario. I need to provide the Scheduler with my own LINQ feed for the Appointment and Resource bindings. Therefore, I need the scheduler's Binding source fully coded by hand as the wizard for the UI component doesn't take LINQ. I have the DB-Level SPs ready and they are implemented as LINQ methods in the DAL project. Kindly help me out here.
  2. Answer
    Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 29 Dec 2010 Link to this post

    Hi Hassan,

    Thank you for writing.

    There is no difference when you use LINQ instead of list with custom objects which represent appointments. The following code snippet demonstrates how to bind RadScheduler using LINQ:

    public partial class Form37 : Form
    {
        List<Appointment> appointments = new List<Appointment>();
        public Form37()
        {
            InitializeComponent();
     
            this.FillAppointments();
     
            this.LoadDateFromLing();
        }
     
        private void FillAppointments()
        {
            this.appointments.Add(new Appointment(this.radScheduler1.ActiveView.StartDate.Date.AddHours(5), new TimeSpan(1, 0, 0), "1"));
            this.appointments.Add(new Appointment(this.radScheduler1.ActiveView.StartDate.Date.AddHours(6), new TimeSpan(2, 0, 0), "1"));
            this.appointments.Add(new Appointment(this.radScheduler1.ActiveView.StartDate.Date.AddHours(5).AddDays(1), new TimeSpan(3, 0, 0), "1"));
            this.appointments.Add(new Appointment(this.radScheduler1.ActiveView.StartDate.Date.AddHours(3).AddDays(2), new TimeSpan(1, 0, 0), "2"));
            this.appointments.Add(new Appointment(this.radScheduler1.ActiveView.StartDate.Date.AddHours(4), new TimeSpan(1, 0, 0), "2"));
        }
     
        private void LoadDateFromLing()
        {
            var apps = from a in this.appointments where a.Summary == "1" select a;
     
            SchedulerBindingDataSource dataSource = new SchedulerBindingDataSource();
            // map the MyAppointment properties to the scheduler
            AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();
            appointmentMappingInfo.Start = "Start";
            appointmentMappingInfo.End = "End";
            appointmentMappingInfo.Summary = "Summary";
            appointmentMappingInfo.Description = "Description";
            appointmentMappingInfo.Location = "Location";
            appointmentMappingInfo.UniqueId = "UniqueId";
            dataSource.EventProvider.Mapping = appointmentMappingInfo;
            // assign the generic List of CustomAppointment as the EventProvider data source
            dataSource.EventProvider.DataSource = apps;
            this.radScheduler1.DataSource = dataSource;
        }
    }

    In case that you have other related questions, feel free to write back.

    Greetings,
    Dobry Zranchev
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top