
I am trying to Implement Sorting & Filtering properties on Gird . I am able to do Sorting but not Filtering.
For this I wrote the code as follows
.aspx:-
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<!-- content start -->
<telerik:RadAjaxManager ID="RadAjaxManager2" DefaultLoadingPanelID="RadAjaxLoadingPanel1"
runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
Width="75px" Transparency="5">
<img style="margin-top: 150px;" alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading4.gif") %>' />
</telerik:RadAjaxLoadingPanel>
<telerik:RadGrid ID="RadGrid1" ShowGroupPanel="True" AllowFilteringByColumn="True"
Skin="Mac" runat="server" AllowPaging="True" AllowCustomPaging="True" PageSize="5"
VirtualItemCount="100" ForeColor="White" OnGroupsChanging="RadGrid1_GroupsChanging"
OnNeedDataSource="RadGrid1_NeedDataSource" AllowSorting="True" GridLines="None">
<%--<MasterTableView VirtualItemCount="25" />--%>
<FooterStyle ForeColor="#FF3300" />
<PagerStyle Mode="Slider"></PagerStyle>
</telerik:RadGrid>
</div>
Aspx.cs:-
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.;database=Pubs;trusted_connection=true");
SqlDataAdapter dap = new SqlDataAdapter("select * from authors", con);
DataSet ds = new DataSet();
dap.Fill(ds, "authors");
this.RadGrid1.DataSource = ds.Tables[0];
this.RadGrid1.DataBind();
}
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
MyBusinessObjectCollection MyBusinessObjectCollection1 = new MyBusinessObjectCollection();
int startRowIndex = (ShouldApplySortFilterOrGroup()) ? 0 : RadGrid1.CurrentPageIndex * RadGrid1.PageSize;
int maximumRows = (ShouldApplySortFilterOrGroup()) ?
MyBusinessObjectCollection1.SelectCount() : RadGrid1.PageSize;
RadGrid1.AllowCustomPaging = !ShouldApplySortFilterOrGroup();
RadGrid1.DataSource = MyBusinessObjectCollection1.Select(startRowIndex, maximumRows);
}
bool isGrouping = false;
public bool ShouldApplySortFilterOrGroup()
{
return RadGrid1.MasterTableView.FilterExpression != "" ||
(RadGrid1.MasterTableView.GroupByExpressions.Count > 0 || isGrouping) ||
RadGrid1.MasterTableView.SortExpressions.Count > 0;
}
protected void RadGrid1_GroupsChanging(object source, GridGroupsChangingEventArgs e)
{
isGrouping = true;
if (e.Action == GridGroupsChangingAction.Ungroup && RadGrid1.CurrentPageIndex > 0)
{
isGrouping = false;
}
}
In above manner I tried,but no use.
Any one can guide me with simple steps to implement Filtering operations
Thanks,
SRRAO.
<
Columns>
<telerik:GridBoundColumn DataField="DEPARTMENT_CODE_ID" HeaderText="Department" UniqueName="column1">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="MODULE_ID" HeaderText="Module" UniqueName="column3">
<EditItemTemplate>
<asp:TextBox ID="MODULE_IDTextBox" runat="server" Text='<%# Bind("MODULE_ID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<telerik:RadComboBox ID="RadComboBox1" runat="server" Enabled="False" SelectedValue='<%# Eval("MODULE_ID") %>'>
<Items>

| <telerik:AjaxUpdatedControl ControlID="optionsTree" LoadingPanelID="AjaxLoadingPanel1"></telerik:AjaxUpdatedControl> |
function onClientSelectedIndexChanged(sender, eventArgs)
{
var combo = $find("ddlStoreID");
var text = eventArgs.get_item().get_text();
var item = combo.findItemByvalue(text);