Server control with RadMenu in RadGrid - raise Click event

2 posts, 0 answers
  1. Fergal
    Fergal avatar
    23 posts
    Member since:
    Jun 2012

    Posted 27 Nov 2012 Link to this post

    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?
  2. Fergal
    Fergal avatar
    23 posts
    Member since:
    Jun 2012

    Posted 27 Nov 2012 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top