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

Handle Selection Events from Menu

1 Answer 8 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
Joel asked on 29 Oct 2020, 05:27 PM

I need to create a filtering mechanism and I'm attempting to figure out the best way to do it.  Yes, I have a post to the Filter forum... but I'm likely going to be told that it is more complex than what the users will want.  So, I have a menu bound to a collection of user-defined Templates as shown.  Each Template has multiple Items as bound to the children/sub-menu.

As the user selects options from this menu, I need to retain the Child Item's Id in order to build a Filter set that I can submit to a REST service.  Because the menu will not provide feedback like your Filter control, I'll need to display the filter in a field that'll grow as they add criteria much like the "ExpressionPreview" on the Filter control.

Template:

public partial class SessionOptionTemplate
{
    public int Id { get; set; }
 
    [MaxLength(50)]
    public string Name { get; set; }
    [MaxLength(128)]
    public string Description { get; set; }
 
    public int Order { get; set; }
 
    public DateTime AddTimestamp { get; set; } = DateTime.UtcNow;
    public DateTime? DeactivateTimestamp { get; set; }
 
    public ICollection<SessionOptionItem> SessionOptionItems { get; set; } = new HashSet<SessionOptionItem>();
}

Item:

public partial class SessionOptionItem
{
    [Key]
    public int Id { get; set; }
    public int SessionOptionTemplateId { get; set; }
 
    [MaxLength(50)]
    public string Name { get; set; }
    [MaxLength(128)]
    public string Description { get; set; }
 
    public DateTime AddTimestamp { get; set; } = DateTime.UtcNow;
    public DateTime? DeactivateTimestamp { get; set; }
}

Menu:

@model IEnumerable<SessionOptionTemplate>
 
@(Html.Kendo().Menu()
    .Name("Menu")
    .Scrollable(true)
    .BindTo(Model, mappings =>
    {
        mappings.For<SessionOptionTemplate>(binding => binding
            .ItemDataBound((item, template) =>
            {
                item.Text = template.Name;
            })
            .Children(category => category.SessionOptionItems));
                mappings.For<SessionOptionItem>(binding => binding
                .ItemDataBound((item, option) =>
                {
                    item.Text = option.Name;
                }));
    }))

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 03 Nov 2020, 02:39 PM

Hi Joel,

To take the ID of the clicked Menu item, I can suggest using the select event of the component. Here is a Dojo example that logs the ID of the clicked Menu item in the console.

I am not sure about the exact filter functionality that you want to implement but such is not available built-in by the Menu component. Maybe someone from the community has experience with your use case scenario and will be able to help you. 

Regards,
Petar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Menu
Asked by
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
Answers by
Petar
Telerik team
Share this question
or