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

e.Appointment.Resources.GetResource returns null

3 Answers 152 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jesper Vognsen Laustsen
Top achievements
Rank 2
Jesper Vognsen Laustsen asked on 22 Jul 2010, 10:46 AM
Hi,

I am trying to do a filter function for my RadScheduler, with a .NET checkboxlist as filter UI control. However, on the AppointmentDataBound event, I cant seem to get anything but NULL from the

e.Appointment.Resources.GetResource function.

Heres my event code:

 

protected

 

void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)

 

{

e.Appointment.Visible =

true;

 

 

foreach (ListItem item in CheckBoxList1.Items)

 

{

 

 

if (item.Selected)

 

{

 

Resource userRes = e.Appointment.Resources.GetResource("Vogne", item.Value);

 

 

if (userRes != null)

 

{

e.Appointment.Visible =

true;

 

}

}

}

}


And here's a part of my markup:

<

 

telerik:RadScheduler ID="RadScheduler1" runat="server" DataDescriptionField="Description"

 

 

DataEndField="End" DataKeyField="ID" DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID"

 

 

DataSourceID="sdsSchedule" DataStartField="Start" DataSubjectField="Subject"

 

 

EnableDescriptionField="True" Skin="Vista" Culture="Danish (Denmark)" FirstDayOfWeek="Monday"

 

 

Height="100%" LastDayOfWeek="Sunday" SelectedView="WeekView" OnAppointmentCreated="RadScheduler1_AppointmentCreated"

 

 

OnFormCreated="RadScheduler1_FormCreated" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound">

 

 

<ResourceTypes>

 

 

<telerik:ResourceType DataSourceID="sdsCategoryA" ForeignKeyField="CategoryA" KeyField="catid"

 

 

Name="Vogne" TextField="catname" />

 

 

</ResourceTypes>

 

 

<AppointmentTemplate>

 

 

<div>

 

 

<b>

 

<%

# Eval("Subject") %>(<%# DataBinder.Eval(Container.Appointment, "Start", "{0:t}") %>-<%# DataBinder.Eval(Container.Appointment, "End", "{0:t}") %>)</b><br />

 

<%

# Eval("Vogne.Text") %>

 

 

</div>

 

 

</AppointmentTemplate>

 

 

</telerik:RadScheduler>

 


...
...

<

 

telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">

 

 

<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True" DataSourceID="sdsCategoryA"

 

 

DataTextField="catname" DataValueField="catid" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged">

 

 

</asp:CheckBoxList>

 

 

</telerik:RadAjaxPanel

 



As you can see, I have a resource, and the CheckBoxList uses the same datasource as the resourceprovider in the Scheduler.

On inserting break point on Resource userRes = e.Appointment.Resources.GetResource("Vogne", item.Value); I can see that the resource has an item that matches my selcted item from the CheckBoxList, but it still evaluates to NULL.

Please HEEELLLP :-)

Regards

Jesper

3 Answers, 1 is accepted

Sort by
0
Jesper Vognsen Laustsen
Top achievements
Rank 2
answered on 22 Jul 2010, 11:11 AM
Obviously one of my tests left a typo in the pasted code:

e.Appointment.Visible = true;


Should indeed have read:

e.Appointment.Visible = false;


But the problem persists ;-)

Jesper

0
Jesper Vognsen Laustsen
Top achievements
Rank 2
answered on 22 Jul 2010, 01:41 PM
Actually, theres a twist to it as well.

If all I do on the AppointmentDataBound event is to set e.Appointment.Visible = true or false, Appointments will be rendered shown or hidden accordingly.

However - if I first set visible = false, then evaluate to change state, I cannot seem to change the state of the appointment. :-| Getting a bit confused about correct approach now.

0
Peter
Telerik team
answered on 27 Jul 2010, 02:12 PM
Hello Jesper,

There is an online example which demonstrates the same functionality:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/resources/defaultcs.aspx

Note, that in FilterAppointment, resourceId is of type int:

private static void FilterAppointment(Appointment appointment, ICheckBoxControl checkBox, int resourceId)
       {
           if (appointment.Resources.GetResource("User", resourceId) != null && checkBox.Checked)
           {
               appointment.Visible = true;
           }
       }

In your case, probably, item.Value returns a string:

Resource userRes = e.Appointment.Resources.GetResource("Vogne", item.Value);

Could you please investigate in that direction and let us know if this was the case?


Cheers,
Peter
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Jesper Vognsen Laustsen
Top achievements
Rank 2
Answers by
Jesper Vognsen Laustsen
Top achievements
Rank 2
Peter
Telerik team
Share this question
or