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

Server control with RadMenu in RadGrid - raise Click event

1 Answer 92 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Fergal
Top achievements
Rank 1
Fergal asked on 27 Nov 2012, 01:21 PM
Hi All,

I have a server control that contains a RadButton, and an associated RadMenu. I have this all working on the page as a stand-alone control.

However, when I click the RadButton, it raises the ItemCommand event for the grid, against the selected GridRow. When I click a menu item, it raises the internal event on the server control, but it is never passed out to the host page.

Ideally, I would like the Button and the Menu portions to expose their events to the host page through the same route (I've got a click event on the server control that both are raising, but I don't think I can hook into this from inside a grid unless I manage some ItemDataBound events - which I don't want the developer to have to do).

I know you can associate a context menu with the grid itself, but this isn't how I want the control to work. Each row has one of these controls, and each has it's own associated RadButton, and RadMenu. Unique to the row.

Is it possible to have the RadMenu inside my control raise the ItemCommand event on the associated grid? Alternatively, is there a way to handle the button click events on the row, without it raising the ItemCommand event?

1 Answer, 1 is accepted

Sort by
0
Fergal
Top achievements
Rank 1
answered on 27 Nov 2012, 01:57 PM
Never mind, I found it. For anyone else in future, All I had to do was call the RaiseBubbleEvent inside my custom control.

I had done that before, but I also needed to set the EventArgs passed in to a CommandEventArgs object:

Private Sub ContextMenu_ItemClicked(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles _ContextMenu.ItemClick
        Dim argument As String = e.Item.Attributes("data-commandargument")
 
        RaiseEvent Click(Me, New SplitButtonEventArgs(e.Item.Value, argument))
 
        'Raise the bubble event so that the Grid ItemCommand event is thrown.
        RaiseBubbleEvent(Me, New CommandEventArgs(e.Item.Value, argument))
    End Sub
Tags
Menu
Asked by
Fergal
Top achievements
Rank 1
Answers by
Fergal
Top achievements
Rank 1
Share this question
or