Filter button

5 posts, 0 answers
  1. Jon
    Jon avatar
    811 posts
    Member since:
    Oct 2008

    Posted 09 Nov 2009 Link to this post

    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?


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 Nov 2009 Link to this post

    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:

  3. DevCraft R3 2016 release webinar banner
  4. Jon
    Jon avatar
    811 posts
    Member since:
    Oct 2008

    Posted 09 Nov 2009 Link to this post

    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  
                            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  
                End If  
            End Sub 
  5. Sebastian
    Sebastian avatar
    9934 posts

    Posted 12 Nov 2009 Link to this post

    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:
    (refer to the demo code implementation)

    Best regards,
    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.
  6. Taiseer
    Taiseer avatar
    37 posts
    Member since:
    Oct 2007

    Posted 25 May 2010 Link to this post

    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?
Back to Top
DevCraft R3 2016 release webinar banner