Feature Request: RadzenPanelMenuItem Click Event #787

Open
opened 2026-01-29 17:43:19 +00:00 by claunia · 0 comments
Owner

Originally created by @SGeorgeFramatome on GitHub (Mar 29, 2023).

I see now RadzenMenuItem has a Click event now, it would be REALLY amazing to get an individual Click event on RadzenPanelMenuItem so I no longer have to take a @Value from RadzenPanelMenuItem and parse dynamic GetType.RunTimeMethods() to find the function that maps to the menu item and, because a singular Click event for the ENTIRE panel menu and all its children is not the best way to go about it when we could have Click events on every item pointing to a specific function as intended.

thank you for reading.!

Cutdown example of what we are doing now, which because we are converting string to function, functions in IDE get targeted as unused etc.

<RadzenPanelMenuItem Value="@("MyFunctionName")" Text="Menu Item X" />
<RadzenPanelMenuItem Value="@("AnotherFunctionAction")" Text="Menu Item Y" />

private Task MyFunctionName()
{
	_nav.NavigateTo($"BusinessLogic/X/?dynamicdata={SessionState.XX}");
	return Task.CompletedTask;
}

private Task AnotherFunctionAction()
{
	_nav.NavigateTo($"SomeOther/ZZZ/?param={SessionState.QQ}");
	return Task.CompletedTask;
}

private Task MenuClicked(MenuItemEventArgs args)
{
	if (args.Value == null) return Task.CompletedTask;
	var methods = this.GetType().GetRuntimeMethods();
	foreach (var m in methods)
	{
		if (m.Name.Equals(args.Value.ToString(), StringComparison.InvariantCultureIgnoreCase))
		{
			return (Task)m.Invoke(this, new object[] { }) ?? throw new InvalidOperationException();
		}
	}
	return Task.CompletedTask;
}

What I really want;

<RadzenPanelMenuItem Click="@(MyFunctionName)" Text="Menu Item X" />
<RadzenPanelMenuItem Click="@(AnotherFunctionAction)" Text="Menu Item Y" />
Originally created by @SGeorgeFramatome on GitHub (Mar 29, 2023). I see now RadzenMenuItem has a Click event now, it would be REALLY amazing to get an individual Click event on RadzenPanelMenuItem so I no longer have to take a @Value from RadzenPanelMenuItem and parse dynamic GetType.RunTimeMethods() to find the function that maps to the menu item and, because a singular Click event for the ENTIRE panel menu and all its children is not the best way to go about it when we could have Click events on every item pointing to a specific function as intended. thank you for reading.! Cutdown example of what we are doing now, which because we are converting string to function, functions in IDE get targeted as unused etc. ```` <RadzenPanelMenuItem Value="@("MyFunctionName")" Text="Menu Item X" /> <RadzenPanelMenuItem Value="@("AnotherFunctionAction")" Text="Menu Item Y" /> private Task MyFunctionName() { _nav.NavigateTo($"BusinessLogic/X/?dynamicdata={SessionState.XX}"); return Task.CompletedTask; } private Task AnotherFunctionAction() { _nav.NavigateTo($"SomeOther/ZZZ/?param={SessionState.QQ}"); return Task.CompletedTask; } private Task MenuClicked(MenuItemEventArgs args) { if (args.Value == null) return Task.CompletedTask; var methods = this.GetType().GetRuntimeMethods(); foreach (var m in methods) { if (m.Name.Equals(args.Value.ToString(), StringComparison.InvariantCultureIgnoreCase)) { return (Task)m.Invoke(this, new object[] { }) ?? throw new InvalidOperationException(); } } return Task.CompletedTask; } ```` What I really want; ```` <RadzenPanelMenuItem Click="@(MyFunctionName)" Text="Menu Item X" /> <RadzenPanelMenuItem Click="@(AnotherFunctionAction)" Text="Menu Item Y" /> ````
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#787