I did add menu using JS.
I want to disable one of the added menu item.
But menu enabled option is readonly.
app.menus.item("$ID/Main").submenus.item("MyTestMenu").menuItems.item("My Menu Item 2").enabled = false;
How to set disable menu?
Indeed, looks like you can't. Only workaround would be to capture the event propagation depending on if you want the action to be run or not.
The trick is, only the ScriptMenuAction.enabled property is rewriteable. This prevents the scripting layer from interfering with regular InDesign menu items.
So, given your custom MenuItem object (myMenuItem), its associatedMenuAction should refer to a ScriptMenuAction which can be disabled:
myMenuItem.associatedMenuAction.enabled = false;
This results in disabling the menu item as well.
Nice one Marc