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

RadScheduler data source

1 Answer 119 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 20 Aug 2012, 08:55 PM
I'm new to using the telerick radscheduler and I'm having problems with loading the scheduler with data.

This is what I have:

 

 

class AppointmentInfo

 

{

 

 

private readonly string _id;

 

 

 

private string _subject;

 

 

 

private DateTime _start;

 

 

 

private DateTime _end;

 

 

 

private string _unit;

 

 

 

private string _clr;

 

 

 

private string _img;

 

 

 

public string ID

 

{

 

 

get { return _id; }

 

}

 

 

public string Subject

 

{

 

 

get { return _subject; }

 

 

 

set { _subject = value; }

 

}

 

 

public DateTime Start

 

{

 

 

get { return _start; }

 

 

 

set { _start = value; }

 

}

 

 

public DateTime End

 

{

 

 

get { return _end; }

 

 

 

set { _end = value; }

 

}

 

 

public string Unit

 

{

 

 

get { return _unit; }

 

 

 

set { _unit = value; }

 

}

 

 

public string Clr

 

{

 

 

get { return _clr; }

 

 

 

set { _clr = value; }

 

}

 

 

public string Img

 

{

 

 

get { return _img; }

 

 

 

set { _img = value; }

 

}

 

 

private AppointmentInfo()

 

{

_id =

 

Guid.NewGuid().ToString();

 

}

 

 

 

public AppointmentInfo(string unitid, DateTime start, DateTime end, string unit, string clr, string img)

 

:

 

this()

 

{

_subject = unitid;

_start = start;

_end = end;

_unit = unit;

_clr = clr;

_img = img;

}

 

 

public AppointmentInfo(Appointment source)

 

:

 

this()

 

{

CopyInfo(source);

}

 

 

public void CopyInfo(Appointment source)

 

{

Subject = source.Subject;

Start = source.Start;

End = source.End;

 

 

 

//Resource unit = source.Resources.GetResourceByType("unit");

 

 

 

//if (user != null)

 

 

 

//{

 

 

 

// UnitID = (int?)unit.Key;

 

 

 

//}

 

 

 

//else

 

 

 

//{

 

 

 

// UnitID = null;

 

 

 

//}

 

 

}

}

 

public

 

 

partial class Calendar : Common.PortalPage

 

 

 

 

 

{

 

 

private const string AppointmentsKey = "Telerik.Web.Examples.Scheduler.BindToList.CS.Apts";

 

 

 

 

 

private List<AppointmentInfo> UnitList

 

{

 

 

get

 

 

 

 

 

{

 

 

List<AppointmentInfo > sessApts = Session[AppointmentsKey] as List<AppointmentInfo>;

 

 

 

if (sessApts == null)

 

{

sessApts =

 

new List<AppointmentInfo>();

 

Session[AppointmentsKey] = sessApts;

}

 

 

return sessApts;

 

}

}

 

 

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

 

if (!IsPostBack)

 

{

Session.Remove(AppointmentsKey);

 

 

ResourceType resType = new ResourceType("unit");

 

resType.ForeignKeyField =

 

"UnitID";

 

RadScheduler1.ResourceTypes.Add(resType);

RadScheduler1.Resources.Add(

 

new Resource("unit", 1, "unit1"));

 

RadScheduler1.Resources.Add(

 

new Resource("unit", 2, "unit2"));

 

RadScheduler1.Resources.Add(

 

new Resource("unit", 3, "unit3"));

 

LoadData();

}

 

RadScheduler1.DataSource = UnitList;

}

 

 

 

private void LoadData()

 

{

 ...get data from sql db

  units = SIMS.BL.Presentation.Contracts.

 

Extensions.GetPortalCalendarUnits(this.UserCredential, request);

 

 

UnitList.Clear();

 

 

foreach (InspectionUnit Unit in units)

 

{

 

    UnitList.Add (

 

new AppointmentInfo(Convert.ToString(Unit.UnitID), (DateTime)(Unit.InsTimeBlockStart),

 

    (

 

DateTime)(Unit.InsTimeBlockEnd), Unit.Unit, Unit.Clr, Unit.Img));

 

}

}

ASPX code:

 

<

 

 

telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

 

 

 

 

 

 

 

 

<AjaxSettings>

 

 

 

 

 

 

 

 

<telerik:AjaxSetting AjaxControlID="RadScheduler1">

 

 

 

 

 

 

 

 

<UpdatedControls>

 

 

 

 

 

 

 

 

<telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1" />

 

 

 

 

 

 

 

 

</UpdatedControls>

 

 

 

 

 

 

 

 

</telerik:AjaxSetting>

 

 

 

 

 

 

 

 

</AjaxSettings>

 

 

 

 

 

 

 

 

</telerik:RadAjaxManager>

 

 

 

 

 

 

 

 

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />

 

 

 

 

 

 

 

 

<td valign="top" >

 

 

 

 

 

 

 

 

<telerik:RadScheduler ID="RadScheduler1" runat="server" SelectedView="WeekView"

 

 

 

Width ="884px" Skin="Web20"

 

 

 

DayStartTime="07:00:00" DayEndTime="20:00:00"

 

 

 

 

 

 

 

 

DataKeyField="ID" DataStartField="Start" DataEndField="End" DataSubjectField="Subject"

 

 

 

 

 

 

 

 

OnAppointmentCreated="RadScheduler1_AppointmentCreated"

 

 

 

onappointmentclick="RadScheduler1_AppointmentClick"

 

 

 

OnNavigationComplete="RadScheduler1_NavigationComplete"

 

 

 

onappointmentinsert="RadScheduler1_AppointmentInsert"

 

 

 

>

 

 

 

 

 

 

 

 

<AdvancedForm Modal = "false" />

 

 

 

 

 

 

 

 

<TimelineView UserSelectable="false" />

 

 

 

 

 

 

 

 

<TimeSlotContextMenuSettings EnableDefault ="true" />

 

 

 

 

 

 

 

 

<AppointmentContextMenuSettings EnableDefault ="true" />

 

 

 

 

 

 

 

 

<Reminders Enabled="false" />

 

 

 

 

 

 

 

 

</telerik:RadScheduler>

 



There are at least three records from the database, I can't figure why the scheduler is not displaying the data?

Thanks in advance for your help
Dan Pocica

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 22 Aug 2012, 02:43 PM
Hello Dan,

Thank you for contacting Telerik Support team,

I did some code modifications to your project and now it displays the data records fine. I completely switched your implementation of LoadData() method with our initializing method, named InitializeAppointments() as demonstrated in this demo. I also deleted the partial class Calendar and moved the UnitList property to the web page class definition. Please find your modified and working project attached to this response.

If you have any further questions, don't hesitate to contact us again.


All the best,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or