This is a migrated thread and some comments may be shown as answers.

Filter button

4 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 09 Nov 2009, 11:37 AM
Hi All,

I have a grid with a set of filterable columns.  Previously I have shown a filter icon for each column, now I want to make it so that in the first column in the grid it displays a filter icon that the user can click to apply any of the filters that have been setup in each row, I have removed the filter icon on all other columns. 

At the moment I have a button in the FilterTemplate for the relevant column and can get the page to do an ajax callback to the .ItemCommand event for the grid as well as intercept the CommandName for the relevant button.  

There doesn't appear to be any RadGrid.ApplyFilters option and from what I have read I need to programatically add all the filters manually.  Is that correct?  If it isn't present it would be a very useful extra bit of functionality for the grid to have.

Any help?

Regards,

Jon

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Nov 2009, 12:07 PM
Hello Jon,

Have you tried out the AutoPostBackOnFilter property for various columns in the grid? If not, check out the following document to gather information on this topic:
AutoPostBackOnFilter

Thanks
Princy.
0
Jon
Top achievements
Rank 1
answered on 09 Nov 2009, 02:01 PM
Hi Princy,

Thanks for that.  Yes I was using the AutoPostBackOnFilter option before but found that more often than not people do two or more filters so I've disabled that functionality and am implementing this instead.  Below is where I am at with this, it works the first time but the second time a filter is performed, the first filter is used and the second is ignored.

In the code I am trying to clear the current filter first and then loop through each column adding it's filter value (if applicable).

As mentioned this seems to work on the first filter attempt but the second click on the Search/Filter button reverts all of the filters back to their values per the first search.

        Private Sub uxRadGrid_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles uxRadGrid.ItemCommand  
            If e.CommandName = "Search" Then  
                uxRadGrid.MasterTableView.FilterExpression = Nothing 
                Dim filteringItem As GridFilteringItem = CType(e.Item, GridFilteringItem)  
                For Each gridcolumn As GridColumn In uxRadGrid.Columns  
                    Try  
                        Dim filterBox As TextBox = CType(filteringItem(gridcolumn.UniqueName).Controls(0), TextBox)  
                        If filterBox.Text <> "" Then  
                            filteringItem.FireCommandEvent("Filter", New Pair(filterBox.Text, e.Item.Attributes("columnUniqueName")))  
                        End If  
                    Catch ex As Exception  
 
                    End Try  
                Next  
                uxRadGrid.MasterTableView.Rebind()  
 
            End If  
        End Sub 
0
Sebastian
Telerik team
answered on 12 Nov 2009, 10:19 AM
Hello Jon,

For your case you will need to build the filter expression manually and append all necessary values to the expression on subsequent filter actions. Further information about how to build  the grid filter expression in code you can gather from the resources below:

http://www.telerik.com/help/aspnet-ajax/grdoperatewithfilterexpression.html

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx
(refer to the demo code implementation)

Best regards,
Sebastian
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.
0
Taiseer
Top achievements
Rank 1
answered on 25 May 2010, 04:18 PM
how it doesn't throw an exception on the below line code?

Dim filteringItem As GridFilteringItem = CType(e.Item, GridFilteringItem)   

You are trying to cast a Saerch Command Item to type grid filtering item, its really urgent to solve this issue please?
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jon
Top achievements
Rank 1
Sebastian
Telerik team
Taiseer
Top achievements
Rank 1
Share this question
or