Excel like filtering - hide filtering symbol in column header

8 posts, 0 answers
  1. V
    V avatar
    4 posts
    Member since:
    Feb 2016

    Posted 23 Feb Link to this post

    Hello, 

    is it possible to hide the filter symbol in a specific column header while excel-like filtering remains enabled? 

    I have to filter a specific column via some radio buttons only.

    This works for me: 

    Private Sub rbAktiv_CheckedChanged(sender As Object, e As EventArgs) Handles rbAktivAuftraege.CheckedChanged
     
            Dim filter As New FilterDescriptor()
            Dim filtervalue As String = String.Empty
            filter.PropertyName = "oa_status"
            filter.[Operator] = FilterOperator.Contains
            filter.IsFilterEditor = True
            Select Case True
                Case sender Is rbAktivAuftraege
                    Me.RGV_auftraege.FilterDescriptors.Clear()
                    filtervalue = CStr("aktiv")
                    filter.Value = filtervalue
                    Me.RGV_auftraege.FilterDescriptors.Add(filter)
    End Select

    Best Regards,

    V. Adler

     

     

     

  2. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 23 Feb Link to this post

    Hello V,

    Thank you for writing.

    If I understand you correctly, you would like to have an excel-like filtering in your RadGridView  and at the same time hide the filter button for some columns, so that they cannot be filtered. This can be easily accomplished by using the ViewCellFormatting event: 
    Private Sub radGridView1_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs)
        If e.CellElement.ColumnInfo.Name = "Age" Then
            Dim cell As GridHeaderCellElement = TryCast(e.CellElement, GridHeaderCellElement)
            If cell IsNot Nothing Then
                cell.FilterButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            End If
        End If
    End Sub

    Detailed information on how cells can be formatted is available here: Formatting Cells.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. V
    V avatar
    4 posts
    Member since:
    Feb 2016

    Posted 23 Feb in reply to Hristo Merdjanov Link to this post

    Hello, 

    thank you for your answer. 

    Unfortunately your code is not working. I made a small and simple demo project with a mysql database and a dataset with project designer. The table in the database has two columns named oakundeID and oa_kunde_name. I tried to hide the cellfilter button in oa_kunde_name but failed.

    This is my code: 

    Imports Telerik.WinControls.UI
    Imports Telerik.WinControls
     
    Public Class Form1
     
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                     Me.Oa_kundeTableAdapter.Fill(Me.OaDataSet.oa_kunde)
        End Sub
        Private Sub radGridView1_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs)
            If e.CellElement.ColumnInfo.Name = "oa_kunde_name" Then
                Dim cell As GridHeaderCellElement = TryCast(e.CellElement, GridHeaderCellElement)
                If cell IsNot Nothing Then
                    cell.FilterButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
                End If
            End If
        End Sub
    End Class

    I attached a screenshot where you can see that the cellfilterbutton is still visible. 

    Additional informaition I forgot in my initial posting: I am using 2015.2.728, not 2016.1.216. 

    Thanks for your help. 

    Best regards,

    V. Adler

  5. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 25 Feb Link to this post

    Hello,

    Thank you for writing back.

    I also tested the solution with the 2015.2.728 version of the assemblies and on my end it is working. Please make sure that indeed the name of your column is the one you validate in the ViewCellFormating event. If you like you can also perform the check by index or the value of the HeaderText property. Please check my code snippet below: 
    Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs)
        'If e.CellElement.ColumnInfo.HeaderText = "Id" Then
        If e.CellElement.ColumnInfo.Index = 0 Then
            Dim cell As GridHeaderCellElement = TryCast(e.CellElement, GridHeaderCellElement)
            If cell IsNot Nothing Then
                cell.FilterButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            End If
        End If
    End Sub

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. V
    V avatar
    4 posts
    Member since:
    Feb 2016

    Posted 25 Feb in reply to Hristo Merdjanov Link to this post

    Hello, thanks for your answer.

    Your code snippet still does not work. Because there is a litte mistake. This is your code:

    01.Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs)
    02.    'If e.CellElement.ColumnInfo.HeaderText = "Id" Then
    03.    If e.CellElement.ColumnInfo.Index = 0 Then
    04.        Dim cell As GridHeaderCellElement = TryCast(e.CellElement, GridHeaderCellElement)
    05.        If cell IsNot Nothing Then
    06.            cell.FilterButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
    07.        End If
    08.    End If
    09.End Sub

    Take a look a line 01: there is no handle clause. So I changed your code to: 

    01.Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting
    02.    'If e.CellElement.ColumnInfo.HeaderText = "Id" Then
    03.    If e.CellElement.ColumnInfo.Index = 0 Then
    04.        Dim cell As GridHeaderCellElement = TryCast(e.CellElement, GridHeaderCellElement)
    05.        If cell IsNot Nothing Then
    06.            cell.FilterButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
    07.        End If
    08.    End If
    09.End Sub

    Finally, this works perfectly. 

    Thanks for your time, best regards, 

    V. Adler

     

  7. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 26 Feb Link to this post

    Hi,

    Thank you for writing. 

    I am glad that you resolved the issue. Actually, the code snippet I sent you is correct, it only misses the subscription to the event which can be performed in the form`s constructor for example:
    Sub New()
     
        InitializeComponent()
     
        AddHandler Me.RadGridView1.ViewCellFormatting, AddressOf RadGridView1_ViewCellFormatting
    End Sub

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. V
    V avatar
    4 posts
    Member since:
    Feb 2016

    Posted 26 Feb in reply to Hristo Merdjanov Link to this post

    Hello, 

    your code snippet is correct, of course.

    I usually subscribe the events via the dropdown menu in the designer so I did not check what you have done.. 

    I apologize for my affront. 

    Best regards, 

    V. Adler

     

  9. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 29 Feb Link to this post

    Hello V,

    Indeed, in VB.NET one can attach event handlers using both approaches. The important thing is that you have accomplished your task.

    Please let me know if I can assist you any further.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready