However, I can't find a way to do the same with the Kendo Menu component. So far, the only I've found to create a menu dynamically is adding a specific ID and getting the menu item with this ID.
Is there a way to get the newly created item and reuse it as the parent reference for the menu?
6 Answers, 1 is accepted
You are correct, the Menu widget append() method returns a reference to the menu itself, not to the appended items. However you can directly append items plus their subitems, using the items property, something like this:
text: "Parent Item",
text: "Sub Item 1"
text: "Sub Item 2"
Does this help in your specific use case? Meanwhile we'll think of a better way to get the last appended items.
the Telerik team
In most cases if you are calling a method where it is valuable to have the new item returned, that should supercede any potential case where you want chaining. Chaining looks nice but it super-unhelpful in these cases.
2 years later, I'm dealing with the same problem again. In the first project, the main menu was more static so I've been able to implement a workaround. This time, I'm trying to generate a dynamic context menu using html tag.
As long as the parent element is the root menu, there's no reference problem. However, when you want to append 2 levels of sub menu using html tag, it would be very useful to get reference to the menu that was created using the append method.
thank you for re-opening this thread. We haven't changed the append method signature, mostly due to backwards compatibility and compliance with the jQuery append method.Regards,
Thank you for the feedback. I am sorry to hear that you are not satisfied with the provided Menu functionality. Could you please send more information about the issue you have problems with? In case you have any ideas or recommendations for improving our widgets or documentation you could always log an issue in our official Feedback Portal. Thus, we could track the interest of the community to the logged request.
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/.