Hello everybody,
Today I want to share short glimps how to Enable/Disable menu item. Let's some menu. For example it looks like this:
Suppose, we added menu action Activate in the following way:
public PXAction<EPEmployee> Activate;
[PXButton]
[PXUIField(DisplayName = "Activate")]
protected virtual IEnumerable activate(PXAdapter adapter)
{
}
// menu action was added like this:
public override void Initialize()
{
Actions.AddMenuAction(Activate);
}
Let's say we want to disable menu item Activate. It can be achieved with usage of RowSelected event and SetEnabled function. In my case I used the following construction:
protected virtual void EPEmployee_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
Actions.SetEnabled("activate", false);//this code will disable menu item activate
}
Take note, that we declared PXAction, which is repsonsible for menu. Then in action Initialize ( this is code from extension class ) we added menu item. And then we can manipulate with enabling/disabling it through Actions.SetEnabled