<telerik:RadGrid runat="server" ID="RadGrid1" ShowStatusBar="true" AllowSorting="True" AllowPaging="True" AllowFilteringByColumn="True" DataSourceID="odsUsers">
<MasterTableView AutoGenerateColumns="false" DataKeyNames="Id" DataSourceID="odsUsers" UseAllDataFields="true">
<Columns>
.........
<telerik:GridTemplateColumn UniqueName="DepartName" AllowFiltering="true">
<ItemTemplate><asp:Label runat="server" ID="Label2" Text='<%# Eval("DepartName") %>' /></ItemTemplate>
<FilterTemplate>
<telerik:RadComboBox ID="cmbDepartments" DataSourceID="odsDepartments" DataTextField="Name" DataValueField="Id" AppendDataBoundItems="true" SelectedValue='<%# filterSelectedDepartment %>' runat="server" OnSelectedIndexChanged="cmbDepartments_SelectedIndexChanged" AutoPostBack="true">
<Items><telerik:RadComboBoxItem Text="All" Value="0" /></Items>
</telerik:RadComboBox>
</FilterTemplate>
</telerik:GridTemplateColumn>
..........
</Columns>
</MasterTableView></telerik:RadGrid><asp:ObjectDataSource ID="odsUsers" runat="server" SelectMethod="GetUsersDataSet" TypeName="TA2009.BusinessLogic.UsersManager" OnSelecting="odsUsers_Selecting">
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsDepartments" runat="server" SelectMethod="GetDepartmentsDataSet" TypeName="TA2009.BusinessLogic.DepartmentsManager" >
</asp:ObjectDataSource>
GetUsersDataSet methods returns a whole list of users. I want to filter them by Department.
protected void cmbDepartments_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox cmbDepartments = o as RadComboBox;
filterSelectedDepartment = cmbDepartments.SelectedValue;
String filter = String.Empty;
if (filterSelectedDepartment != "0")
filter = "DepartId=" + filterSelectedDepartment;
RadGrid1.MasterTableView.FilterExpression = filter ;
RadGrid1.Rebind();
}
When filter is applied, only filtered rows remains in the grid, this is right. But number of pages and records in the paging panel remains the same as it was.
For example, let's assume that grid contains 7 records, 5 records are displaing on the page, i.e. there are 2 pages, 5 records on the first page and 2 on the second. Let's assume that only 2 records satisfy to filter criteria, 1 on the first page and 1 on the second. In this case when filter is appplied, I will still get a grid with 2 pages, 1 record will be displayed on the first page and one on the second.
I thought , that I should get a grid with 1 page and 2 records displaying on it.
Please advice.