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

Hide not AllowSearching columns in the search box ContextMenu

2 Answers 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
QQ
Top achievements
Rank 1
QQ asked on 03 Jun 2019, 10:20 PM

I want to exclude some columns from searching.  I set the column AllowSearching = false.  The column name is still showing in the 'Search in Columns' menu unchecked.  Can I hide those columns?  I tried :

DirectCast(DirectCast(e.ContextMenu, Telerik.WinControls.UI.RadDropDownButtonPopup).Items(0), Telerik.WinControls.UI.RadMenuItem).Items(i).Visibility = ElementVisibility.Hidden

It hides the menu item with the column name but showing a empty item in the position.  Anyway I can make it disappear?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 04 Jun 2019, 11:19 AM
Hi Flora,

You need to set the menu item Visibility property to Collapsed. It will not display the item and will not reserve a space for it. Please refer to the following code snippet:
Private Sub RadGridView1_ContextMenuOpening(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs)
        Dim popup = TryCast(e.ContextMenu, RadDropDownButtonPopup)
 
        If popup IsNot Nothing Then
            Dim item As RadMenuItem = TryCast(popup.Items(0), RadMenuItem)
 
            For Each menuItem In item.Items
 
                If menuItem.Text = RadGridView1.Columns(0).Name Then
                    menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
                End If
            Next
        End If
    End Sub

I hope this will be useful. Should you have further questions, I would be glad to help.

Regards,
Nadya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
QQ
Top achievements
Rank 1
answered on 04 Jun 2019, 01:53 PM
Thank you.  It works.
Tags
GridView
Asked by
QQ
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
QQ
Top achievements
Rank 1
Share this question
or