RadGrid Filtermenu Customisation

1 posts, 0 answers
  1. Johan
    Johan avatar
    5 posts
    Member since:
    Aug 2017

    Posted 03 Jan Link to this post

    Hello,

    so im trying to add a button to the first cell in the Filtermenu with a 'Clear all filters' functionality. However i cant seem to get a handle on the first cell.

    Here's some testing that i've tried so far with various examples i've found over the internet.

    Private Sub Grid_OnItemCreated(sender As Object, e As GridItemEventArgs)
                If e.Item.ItemType = GridItemType.FilteringItem Then
                    Dim clearFilterButton = New RadButton() With {.ButtonType = RadButtonType.StandardButton,
                                                                  .Height = 22,
                                                                  .Width = 22,
                                                                  .Text = "Clear Filter",
                                                                  .ToolTip = "Clear all filters"}
     
                    AddHandler clearFilterButton.Click, AddressOf ClearFilterButton_Click
                    Dim grid As RadGrid = CType(sender, RadGrid)
     
                    Dim firstcell = grid.Controls(0)
                    firstcell.Controls.Add(clearFilterButton)
                End If
            End Sub
     
            Private Sub ClearFilterButton_Click(sender As Object, e As EventArgs)
                For Each grid As RadGrid In Controls.All().OfType(Of RadGrid)()
                    grid.MasterTableView.FilterExpression = String.Empty
                    grid.Rebind()
                Next
            End Sub

     

    I cant seem to get it to do anything at all tho. Even just trying to hide the Filtermenu does not seem to do anything. And yes the event is firing, it is triggered in the basepage load. Is this the way to add a button to a filtermenu? Or is there a better way?

    Regards

     

     

     

     

     

     

Back to Top