How to filter rad grid using context menu select value in vb ?

1 Answer 16 Views
GridView
Aravind
Top achievements
Rank 2
Iron
Iron
Iron
Aravind asked on 04 Jul 2024, 08:48 AM
Hi,
    I can add context menu when right click on the grid, but based on selected value from context menu, i want to hide / show the rows.
Ex: Grid have 4 column's,  One of the column name is "Status", in that we get "Export" , "Done" and "Pending" for each rows, so i show there 3 values in context menu when right click on the grid using following code


'Declaration Private contextMenu1 As RadContextMenu 'Page Load contextMenu1 = New RadContextMenu() Dim menuItem1 As New RadMenuItem("Export") menuItem1.ForeColor = Color.Red AddHandler menuItem1.Click, AddressOf rmi1_Click Dim menuItem2 As New RadMenuItem("Verification") AddHandler menuItem2.Click, AddressOf rmi2_Click contextMenu1.Items.Add(menuItem1) contextMenu1.Items.Add(menuItem2) 'Code for show context menu Private Sub RadGridView1_ContextMenuOpening(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles RadGridView1.ContextMenuOpening e.ContextMenu = contextMenu1.DropDown End Sub 'Menu click event Private Sub rmi2_Click(sender As Object, e As EventArgs) sender.Visible = CDec(sender.Row.Cells("Status").Value) = "Export" End Sub Private Sub rmi1_Click(sender As Object, e As EventArgs) sender.Visible = CDec(sender.Row.Cells("Status").Value) = "Done" End Sub

 Private Sub rmi1_Click(sender As Object, e As EventArgs)
        sender.Visible = CDec(sender.Row.Cells("Status").Value) = "Pending"
 End Sub

Thanks and Regards
Aravind

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 08 Jul 2024, 11:40 AM

Hi Aravind,

The sender in the Click event of the RadMenuItem will be the menu item itself. Here you will need to target the RadGridView instead of using the sender. Here is what I have in mind.

Private Sub rmi1_Click(sender As Object, e As EventArgs)
    Me.RadGridView1.CurrentRow.IsVisible = Me.RadGridView1.CurrentRow.Cells("Status").Value = "Pending"
End Sub

In general, I would suggest to remove the item from the source instead of hiding. If the user wants it back, you can re-add it again.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Aravind
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or