I am using radgrid and I have filters for some 4 col in my grid
These 4 cols are string,string,integer and decimal data columns
I have currentfilterfunction for the integer and decimal as "greaterthanequalto" and for others string i havent set.(which means default equal to)
For the first time when I filter all works fine.
Once when I filter the string columns (which is = filter)....it filters and then when I filter the age or amount for greater than (>=) ...it doesnt filter for that....instead filters only for = .
Can someone tell me why?
4 Answers, 1 is accepted
Please note that the default filter function for grid columns with DataType of String is Contains as described here in the AutoPostBackOnFilter section.
However, could you please share your grid declaration and data-binding code so we could check your case further?
Regards,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
| <telerik:RadGrid ID="RadGrid1" runat="server" ShowStatusBar="true" Visible = "false" |
| AutoGenerateColumns="false" PageSize="25" AllowSorting="True" AllowMultiRowSelection="False" OnItemCreated="RadGrid1_ItemCreated" |
| AllowPaging="True" AllowFilteringByColumn ="true" EnableLinqExpressions="false" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemDataBound= "RadGrid1_OnItemDataBound" |
| OnItemCommand = "RadGrid1_ItemCommand" > |
| <PagerStyle Mode="NumericPages"></PagerStyle> |
| <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true"> |
| <Resizing |
| AllowRowResize="True" |
| EnableRealTimeResize="True" |
| ResizeGridOnColumnResize="True" |
| AllowColumnResize="True" /> |
| <Selecting AllowRowSelect ="true" /> |
| </ClientSettings> |
| <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="Oid"> |
| <CommandItemTemplate> |
| <div style="text-align:right"> |
| <asp:LinkButton ID = "lnlClearFilter" runat="server" CommandArgument="0" CommandName = "Clear Filters" OnClick = "btnClearFilter"><img style="border:0px;vertical-align:middle;" alt="" src="../images/EditRecord.gif" />Clear Filters</asp:LinkButton> |
| <asp:LinkButton ID = "lnkMarkPay" runat="server" CommandArgument="0" CommandName = "Mark Pay" OnClientClick = "javascript:return Confirm('Pay');" OnClick = "btnMarkPay"><img style="border:0px;vertical-align:middle;" alt="" src="../images/EditRecord.gif" />Pay</asp:LinkButton> |
| <asp:LinkButton ID = "lnkMarkHold" runat="server" CommandArgument="1" CommandName = "Mark Hold" OnClientClick = "javascript:return Confirm('Hold');" OnClick = "btnMarkPay"><img style="border:0px;vertical-align:middle;" alt="" src="../images/EditRecord.gif" />Hold</asp:LinkButton> |
| <asp:HyperLink ID = "lnkButtonHideCriteria" runat="server" NavigateUrl="#" OnClick="javascript:ShowCriteria(true);" ><img style="border:0px;vertical-align:middle;" alt="" src="../Images/checkbook.gif" /> Create Check Run</asp:HyperLink> |
| <asp:LinkButton ID = "lnkReset" runat="server" NavigateUrl="#" OnClientClick="javascript:return Confirm('Reset');" OnClick = "btnReset"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/EditRecord.gif" /> Reset</asp:LinkButton> |
| <asp:LinkButton ID = "lnkButtonAddExportExcel" runat="server" CommandName="ExportExcel" OnClick="RadGrid1_ExportCommand"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icxls.gif" /> Export to Excel</asp:LinkButton></div> |
| </CommandItemTemplate> |
| <Columns> |
| <telerik:GridBoundColumn DataField="Oid" AllowFiltering="false" HeaderText="Oid" Visible="false" /> |
| <telerik:GridBoundColumn DataField="CompanyName" AllowFiltering="false" HeaderText="Company" Visible="true" ItemStyle-BorderStyle="Solid" ItemStyle-Width="50px" HeaderStyle-Width="50px"/> |
| <telerik:GridBoundColumn DataField="DepartmentName" AllowFiltering = "true" ShowFilterIcon = "false" AutoPostBackOnFilter="true" HeaderText="Dept." Visible="true" FilterControlWidth = "45px" ItemStyle-BorderStyle="Solid" ItemStyle-Width="60px" HeaderStyle-Width="60px"/> |
| <telerik:GridBoundColumn DataField="InvType" AllowFiltering="false" HeaderText="Bus. Unit" Visible="false" ItemStyle-BorderStyle="Solid" ItemStyle-Width="10px" HeaderStyle-Width="10px" /> |
| <telerik:GridBoundColumn DataField="Voucher" AllowFiltering="false" HeaderText="Voucher" Visible="true" ItemStyle-BorderStyle="Solid" ItemStyle-Width="100px" HeaderStyle-Width="100px"/> |
| <telerik:GridBoundColumn DataField="InvoiceNumber" AllowFiltering="false" HeaderText="Invoice" Visible="false" ItemStyle-BorderStyle="Solid" ItemStyle-Width="10px" HeaderStyle-Width="10px"/> |
| <telerik:GridTemplateColumn HeaderText="Inv. Number" AllowFiltering="false" SortExpression="InvoiceNumber" ItemStyle-BorderStyle="Solid" ItemStyle-Width="90px" HeaderStyle-Width="90px" > |
| <ItemTemplate> |
| <a target="_blank" style="text-decoration:underline; color :Blue;" href="../<%# ((ENPInv.InvoiceDisplay)Container.DataItem).ShowInvoiceURL()%>"> <%# DataBinder.Eval(Container.DataItem, "InvoiceNumber") %></a> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="InvoiceAmount" AllowFiltering = "true" UniqueName="Amount" AutoPostBackOnFilter="true" ShowFilterIcon="false" HeaderText="Amount" FilterControlWidth="60px" DataFormatString="{0:C2}" Visible="true" ItemStyle-BorderStyle="Solid" ItemStyle-Width="75px" HeaderStyle-Width="75px"/> |
| <telerik:GridBoundColumn DataField="VendorName" AllowFiltering = "true" AutoPostBackOnFilter="true" HeaderText="Vendor" ShowFilterIcon = "false" Visible="true" FilterControlWidth = "150px" ItemStyle-BorderStyle="Solid" ItemStyle-Width="200px" HeaderStyle-Width="200px"/> |
| <telerik:GridBoundColumn DataField="Age" AllowFiltering = "true" AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth = "25px" HeaderText="Age" Visible="true" ItemStyle-BorderStyle="Solid" ItemStyle-Width="75px" HeaderStyle-Width="75px" /> |
| <telerik:GridBoundColumn DataField="InvoiceDate" AllowFiltering="false" HeaderText="Invoice Date" Visible="true" DataFormatString="{0:MM-dd-yyyy}" ItemStyle-BorderStyle="Solid" ItemStyle-Width="75px" HeaderStyle-Width="75px" /> |
| <telerik:GridBoundColumn DataField="DueDate" AllowFiltering="false" HeaderText="Date Due" Visible="true" DataFormatString="{0:MM-dd-yyyy}" ItemStyle-BorderStyle="Solid" ItemStyle-Width="75px" HeaderStyle-Width="75px" /> |
| <telerik:GridBoundColumn DataField="PendingAction" AllowFiltering="false" HeaderText="Pending Action" Visible="false" ItemStyle-BorderStyle="Solid" ItemStyle-Width="10px" HeaderStyle-Width="10px"/> |
| <telerik:GridBoundColumn DataField="ViewStatus" AllowFiltering="false" HeaderText="ViewHidden" Visible="false" ItemStyle-BorderStyle="Solid" ItemStyle-Width="0px" HeaderStyle-Width="0px"/> |
| <telerik:GridTemplateColumn HeaderText="Status" AllowFiltering="false" SortExpression="PendingAction" ItemStyle-BorderStyle="Solid" ItemStyle-Width="75px" HeaderStyle-Width="75px" > |
| <ItemTemplate> |
| <asp:Panel ID= "Panel1" runat = "server"> |
| <table> |
| <tr> |
| <td> |
| <asp:CheckBox ID = "chkToggleStatus" runat = "server" OnCheckedChanged = "chkToggleStatus_Click" AutoPostBack ="true" /> </td> |
| <td><asp:LinkButton ID="btnToggleStatus" Enabled="false" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Voucher") %>' style="color:Blue;"> |
| </asp:LinkButton></td> |
| </tr> |
| </table> |
| </asp:Panel> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
| { |
| if (LoadType == "Disbursement") |
| { |
| if (!e.IsFromDetailTable) |
| { |
| if (!IsPostBack) |
| { |
| RadGrid1.DataSource = GetInvoicesForDisbursement(1); |
| // to make filter case insensitive |
| RadGrid1.GroupingSettings.CaseSensitive = false; |
| } |
| else |
| { |
| List<ENPInv.InvoiceDisplay> dummy = new List<ENPInv.InvoiceDisplay>(); |
| dummy.Add(new ENPInv.InvoiceDisplay()); |
| RadGrid1.DataSource = dummy; |
| } |
| } |
| } |
| } |
| protected void RadGrid1_OnItemDataBound(object source, Telerik.Web.UI.GridItemEventArgs e) |
| { |
| if (e.Item.ItemType == Telerik.Web.UI.GridItemType.Item || e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem) |
| { |
| InvoiceDisplay obj = (InvoiceDisplay)e.Item.DataItem; |
| LinkButton button = (LinkButton)e.Item.FindControl("btnToggleStatus"); |
| if (obj.PayDisposition == "P") |
| { |
| CheckBox chk = (CheckBox)e.Item.FindControl("chkToggleStatus"); |
| chk.Checked = true; |
| chk.Attributes.Add("onchange", "javascript:return Call();"); |
| e.Item.Cells[15].Text = "Pay"; |
| button.Text = "Pay"; |
| } |
| else |
| { |
| e.Item.Cells[15].Text = "Hold"; |
| button.Text = "Hold"; |
| } |
| } |
| } |
this is my grid declaration and binding functionality.
As i said earlier, I am having filtering for columns Vendor,Department,Amount,Age.
Vendor and Departemnt are string types and default has "contains" as currentfilterfunction . For Amount and Age I have "greaterthanequalto" as currentfilterfunction.
So when first time i filter age or amount it filters with "greaterthanorequalto" and after that if i filter vendorname or department, it filters with contains which it is suppose to . Now with the filtered values if i again try to filter age or amount it filters with contains or equal to and not with "greaterthanequalto" which it is suppose to do....i think when we currentfilterfunction it is default filter criteria for that column.
Please let me know in case if u have not understood my problem?..
thanks
I went through your code however I was not able to find where you are setting the problematic columns CurrentFilterFunction property. Let me know if I missed something out there.
Additionally, I prepared a sample project for you illustrating the desired functionally. Check it out and see it helps.
Kind regards,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.