Add submenu items via API

I would like to attach/add submenu items via API to an existing menu. I can able to do for menu item by using
$$(“data”).add({
title: document.getElementById(“title”).value,
year: document.getElementById(“year”).value
},0)

How to do it for submenu?. can I just give only the submenu JSON?

You can use getSubMenu(id) method to get submenu of the a certain item.

Thank you. Am trying to add in this example, http://webix.com/snippet/adb1b0f5 but always getting the id as undefined. How do I add it?.

I coded with different approach. http://webix.com/snippet/d437f333
Is that the right way?. How do I remove the submenu using API? I have tried $$(‘menuPopup’).remove(‘menuid’) it always removes from main menu.

How to find the parent of an submenu so that I can execute function handleMachine according to the ids edit or delete.

any help?

getSubMenu gets submenu that contains an item with a certain id.

So, if submenu is empty, there is not possibility to get a submenu.

Here is the demo:

http://webix.com/snippet/9e911606