动作按钮未在屏幕上更新

时间:2019-08-19 13:11:13

标签: acumatica

我在QuoteMaint图上有一个操作按钮。该操作位于操作文件夹中。我根据报价状态设置是否启用按钮。当用户提交报价时,应启用操作按钮。我逐步执行了代码,它运行了例程以启用按钮,但是在屏幕上却未启用。刷新屏幕时,它没有问题。下面的代码,谢谢您的帮助!

    public PXAction<CRQuote> printQuoteSummary;

    [PXButton(CommitChanges = true, SpecialType = PXSpecialButtonType.Report)]
    [PXUIField(DisplayName = "Print Quote - Summary")]
    public IEnumerable PrintQuoteSummary(PXAdapter adapter)
    {
        Dictionary<string, string> parameters = new Dictionary<string, string>();
        string actualReportID = "CR604510";

        foreach (CRQuote item in adapter.Get<CRQuote>())
        {
            parameters[nameof(CRQuote.OpportunityID)] = item.OpportunityID;
            parameters[nameof(CRQuote.QuoteNbr)] = item.QuoteNbr;

            throw new PXReportRequiredException(parameters, actualReportID, "Report " + actualReportID);
        }
        return adapter.Get();
    }

    public override void Initialize()
    {
        base.Initialize();
        Base.actionsFolder.AddMenuAction(printQuoteSummary);
        Base.Actions.Move("PrintQuote", "printQuoteSummary");
        printQuoteSummary.SetEnabled(Base.Quote.Current?.Status == CRQuoteStatusAttribute.Approved || Base.Quote.Current?.Status == CRQuoteStatusAttribute.Sent);
    }

    protected virtual void CRQuote_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
    {
        CRQuote quote = e.Row as CRQuote;
        if (quote == null) return;

        using (new PXConnectionScope())
        {
            CalcTotals(quote);
        }

        printQuoteSummary.SetEnabled(quote.Status == CRQuoteStatusAttribute.Approved || quote.Status == CRQuoteStatusAttribute.Sent);
    }

1 个答案:

答案 0 :(得分:1)

为事件委托添加其他参数可以解决测试中的问题,请在下面找到示例。

    protected virtual void CRQuote_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
    {
        del?.Invoke(cache, e);
        CRQuote quote = e.Row as CRQuote;
        if (quote == null) return;

        using (new PXConnectionScope())
        {
            CalcTotals(quote);
        }
        PrintQuoteSummary.SetEnabled(quote.Status == CRQuoteStatusAttribute.Approved || quote.Status == CRQuoteStatusAttribute.Sent);
    }

与此同时,您也可以删除初始化方法中启用/禁用的引用,如下所示。

    public override void Initialize()
    {
        base.Initialize();
        Base.actionsFolder.AddMenuAction(PrintQuoteSummary);
        Base.Actions.Move("PrintQuote", "printQuoteSummary");
    }