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

Custom Data Binding

1 Answer 99 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
DoomerDGR8 asked on 24 Dec 2010, 11:26 AM
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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Dobry Zranchev
Telerik team
answered on 29 Dec 2010, 11:53 AM
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.
Tags
Scheduler and Reminder
Asked by
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dobry Zranchev
Telerik team
Share this question
or