I have a Scheduler bound to an ObjectDataSource that I want to filter using a dropdown list of Categories. I have a ControlParameter as a SelectParameter on the ObjectDataSource tied to this dropdown. My filtering works fine if I select an Category that has appointments associated with it and actually returns rows. However, if I select a Category that does not have any appointments associated with it and returns no rows, the Scheduler never updates and continues to show the previous list of appointments instead of showing no appointments. Any idea on why the Scheduler won't refresh and properly show no appointments in this situation?
4 Answers, 1 is accepted
We are not aware of such issue with RadScheduler filtering in server side binding. You can refer to this sample demo where the appointments are filtered depending on checkboxes and this functionality is still working correctly event when unchecking all of them.
Regards,
Plamen
Telerik
In that demo, you aren't filtering on the datasource though, you're simply returning all rows and then filtering. The problem occurs if you filter the datasource itself using SelectParameters and it returns no rows. As an example, I have a dropdown list of categories that is used as a ControlParameter on my datasource as defined below. When I initially visit the page, all appointments are loaded because no category is selected. If I select a category that has no appointments and thus the datasource returns 0 rows, instead of showing no appointments, the calendar still displays all appointments.
I think if you modify your that demo example and add a dropdown list of Rooms and modify the SqlDataSource as shown below, you should be able to reproduce the issue. It doesn't look like any of the appointments in that demo are assigned to a room number, so as soon as you try to select a room from the dropdownlist, it should filter the datasource such that the select statement returns 0 rows. However the calendar itself will not update and will continue to show all appointments. Again, the issue seems to arise when the datasource goes from returning greater than 0 rows, to returning exactly 0 rows.
<
asp:DropDownList
runat
=
"server"
ID
=
"ddlRooms"
DataSourceID
=
"RoomsDataSource"
DataTextField
=
"RoomName"
DataValueField
=
"ID"
AppendDataBoundItems
=
"true" AutoPostBack="true"
>
<
asp:ListItem
Text
=
""
Value
=
"0"
></
asp:ListItem
>
</
asp:DropDownList
>
<
asp:SqlDataSource
ID
=
"AppointmentsDataSource"
runat
=
"server"
ProviderName
=
"System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:TelerikConnectionString35 %>"
SelectCommand="SELECT * FROM [Appointments] Where @RoomID = 0 Or (@RoomID <> 0 And RoomID = @RoomID)" InsertCommand="INSERT INTO [Appointments] ([Subject], [Start], [End], [RoomID], [UserID], [RecurrenceRule], [RecurrenceParentID]) VALUES (@Subject, @Start, @End , @RoomID, @UserID, @RecurrenceRule, @RecurrenceParentID)"
UpdateCommand="UPDATE [Appointments] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [RoomID] = @RoomID, [UserID] = @UserID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID WHERE (ID = @ID)"
DeleteCommand="DELETE FROM [Appointments] WHERE [ID] = @ID">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"ddlRooms"
PropertyName
=
"SelectedValue"
Name
=
"RoomID"
Type
=
"Int32"
/>
</
SelectParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int32"
></
asp:Parameter
>
</
DeleteParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int32"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Subject"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Start"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"End"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"RoomID"
Type
=
"Int32"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"UserID"
Type
=
"Int32"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"RecurrenceRule"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"RecurrenceParentID"
Type
=
"Int32"
></
asp:Parameter
>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"Subject"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Start"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"End"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"RoomID"
Type
=
"Int32"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"UserID"
Type
=
"Int32"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"RecurrenceRule"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"RecurrenceParentID"
Type
=
"Int32"
></
asp:Parameter
>
</
InsertParameters
>
</
asp:SqlDataSource
>
I have modified the demo as per your suggestion and the RadScheduler behaves correctly when the data source is filtered by room. Here is a video of the behaviour at my end. The sample which I have tested with is attached.
Regards,
Dimitar Terziev
Telerik