Action pane control in form extension class

Hello,

   I am trying disable a an action pane control(formmenufunctionbuttonControl) based on some condition. But i could not able to do this. Following is the code snippet i have written to disable the control. Can you guys please help me on this? Thanks for you help

[extensionof(formStr(ProjTable))]
final public static class ProjTableFormBAS_Extension
{
[PostHandlerFor(formStr(ProjTable), formMethodStr(ProjTable, init))]
public static void ProjTable_Post_init(XppPrePostArgs args)
{
    FormRun formRun = args.getThis();
   var forecastdelete = formRun.design().controlName("ProjForecastBudgetDelete");


   forecastdelete.enabled(false);
}

}

Parents
No Data
Reply
  • What problem do you have your code? It executes correctly but it doesn't have any effect? Or you can't get a reference to the control? Or what?

    Also, why are you using the old mode with XppPrePostArgs? It's ugly and error-prone. This is your code rewritten with Chain of Command:

    public void init()
    {
        next init();
    
    	var forecastdelete = this.design().controlName("ProjForecastBudgetDelete");
    	forecastdelete.enabled(false);
    }

    Or you can subscribe to the Initialized event:

    [FormEventHandler(formStr(ProjTable), FormEventType::Initialized)]
    public static void ProjTable_OnInitialized(xFormRun sender, FormEventArgs e)
    {    
    	var forecastdelete = sender.design().controlName("ProjForecastBudgetDelete");
    	forecastdelete.enabled(false);   
    }

    (I used Insert > Insert code to keep the code nicely formatted.)

Children
No Data
Related
Recommended