首页 > 解决方案 > 如何强制在账单和调整屏幕的文档详细信息网格上启用字段

问题描述

我目前正试图强制在 RowSelected 事件上启用一个字段,我之前已经开始工作,但现在它没有。

当账单处于禁用网格的状态时,我添加了两个希望保持启用状态的用户字段。

我正在使用的代码是这样的,我认为它会起作用:

    protected virtual void APTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
    {
        var aptran = e.Row as APTran;
        if (aptran != null)
        {
            PXUIFieldAttribute.SetEnabled<APTranExt.usrGrantID>(cache, aptran, true);
            PXUIFieldAttribute.SetEnabled<APTranExt.usrReimbursementPeriod>(cache, aptran, true);
        }
    }

但它不起作用。

有任何想法吗?

谢谢...

标签: acumatica

解决方案


最有可能发生的事情是视图当前将允许更新设置为 false,这会覆盖您正在设置的启用状态。绕过此问题的一种方法是,对于该状态,您将允许更新设置为 true。然后强制禁用整个网格,除了您想要的两个字段。下面的例子:

protect virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
    if (e.Row is APinvoice row)
    {
        if (status)
        {
            Transactions.Cache.AllowUpdate = true
            PXUIFieldAttribute.SetEnabled(Transactions.Cache, null, false);
            PXUIFieldAttribute.SetEnabled<APTranExt.usrGrantID>(Transactions.Cache, null, true);
            PXUIFieldAttribute.SetEnabled<APTranExt.usrReimbursementPeriod>(Transactions.Cache, null, true);
        }
    }
}

推荐阅读