I have set up the resources for my scheduler like in this example: http://www.telerik.com/help/aspnet-ajax/scheduler-using-datasource-property.html. I have the scheduler to group by the Room resource.
I have then created a custom filter where the user can select a subset of resources (rooms). When the user change the filter, I alter the Rooms property to hold the selected rooms and call RadScheduler.Rebind(). This does, however, not change anything. All resources are still displayed in the calendar. Am I using the correct approach?
I have then created a custom filter where the user can select a subset of resources (rooms). When the user change the filter, I alter the Rooms property to hold the selected rooms and call RadScheduler.Rebind(). This does, however, not change anything. All resources are still displayed in the calendar. Am I using the correct approach?
7 Answers, 1 is accepted
0
Esben
Top achievements
Rank 1
answered on 20 Dec 2012, 09:05 AM
Ok, I found a solution that seems to work, but I'm not sure if it's ugly or not....
I simply clear the collection of resource types everytime the user changes the filter and applies the filter in the Rooms property. The user selects rooms in the control SelectRoom and clicks a button. The button eventhandler then calls a method that clears the Room resource type and adds it again. Is this the right way to go?
I simply clear the collection of resource types everytime the user changes the filter and applies the filter in the Rooms property. The user selects rooms in the control SelectRoom and clicks a button. The button eventhandler then calls a method that clears the Room resource type and adds it again. Is this the right way to go?
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
AddOrUpdateResource();
}
}
private
void
AddOrUpdateResource()
{
RadScheduler1.ResourceTypes.Clear();
var rt =
new
ResourceType(
"Room"
)
{
DataSource = Rooms,
KeyField =
"RoomNo"
,
ForeignKeyField =
"RoomNo"
,
TextField =
"RoomName"
};
RadScheduler1.ResourceTypes.Add(rt);
}
protected
void
FilterButton_OnClick(
object
sender, EventArgs e)
{
AddOrUpdateResource();
}
private
List<Room> Rooms
{
get
{
var sessRooms = Session[RoomKey]
as
List<Room>;
if
(sessRooms ==
null
)
{
sessRooms = _backendManager.GetRooms();
Session[RoomKey] = sessRooms;
}
var selectedRoomNumbers =
(from ListItem item
in
SelectRoom.Items where item.Selected select item.Value).ToList();
if
(selectedRoomNumbers.Any())
{
sessRooms = sessRooms.Where(x => selectedRoomNumbers.Contains(x.RoomNo)).ToList();
}
return
sessRooms;
}
set
{ Session[RoomKey] = value; }
}
0
Hi Esben,
Plamen
the Telerik team
The approach you are using looks correct. I am attaching one sample web page where similar behavior have been implemented with a RadCombobox with CheckBoxes.
Hope this will be helpful.
Plamen
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.
0
Esben
Top achievements
Rank 1
answered on 20 Dec 2012, 06:43 PM
Hi Plamen
Thanks for your response. So by agreeing to my approach, do you say that Rebind() does not rebind the datasource of resourcetypes? Does it only rebind the scheduler's datasource? Or neither?
Thanks for your response. So by agreeing to my approach, do you say that Rebind() does not rebind the datasource of resourcetypes? Does it only rebind the scheduler's datasource? Or neither?
0
Accepted
Hi Esben,
After reviewing the code you provided once again I would rather recommend you to use the approach suggested in the project I sent you in my previous post.
As for the Rebind method it is rebinding both the appointments and returning the resource types to their initial state and count.
Hope this will be helpful.
All the best,
Plamen
the Telerik team
After reviewing the code you provided once again I would rather recommend you to use the approach suggested in the project I sent you in my previous post.
As for the Rebind method it is rebinding both the appointments and returning the resource types to their initial state and count.
Hope this will be helpful.
All the best,
Plamen
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.
0
Esben
Top achievements
Rank 1
answered on 03 Jan 2013, 02:21 PM
I have now implemented an approach similar to the one in the example - I agree that this way of doing it seems more reasonable.
The custom filters work fine, when I filter by a resource type which is used in the GroupBy property of the RadScheduler (in this situation the columns of the resources that are not selected in the filter are simply removed from the scheduler). But if I try to filter by a resource type which is not used in the GroupBy property, this method does not work.
How do I filter by resource types that are not used in GroupBy?
The custom filters work fine, when I filter by a resource type which is used in the GroupBy property of the RadScheduler (in this situation the columns of the resources that are not selected in the filter are simply removed from the scheduler). But if I try to filter by a resource type which is not used in the GroupBy property, this method does not work.
How do I filter by resource types that are not used in GroupBy?
0
Esben
Top achievements
Rank 1
answered on 03 Jan 2013, 03:15 PM
I solved it by setting Appointment.Visible to true/false in the OnAppointmentDataBound event.
Please let me know if that is not the most efficient way to do it.
Please let me know if that is not the most efficient way to do it.
0
Hi Esben,
Plamen
the Telerik team
Yes indeed, when you are trying to filter the Appointments that are not used in the GroupBy property a nice way to achieve it is by hiding them in the AppointmentDataBound event as you did in your scenario.
Plamen
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.