首页 > 解决方案 > 我可以以编程方式关闭智能面板吗?

问题描述

我想在单击按钮时运行验证,如果验证通过,也会关闭智能面板。有没有办法以编程方式关闭智能面板?

标签: acumatica

解决方案


首先 - 在 SmartPanel 上,您需要添加一个按钮并将属性“对话结果”设置为“确定”值。

px:PXButton runat="server" ID="OkButton" Text="Ok" DialogResult="OK"

第二 - 你可以使用下面的代码(它是用stackOverflow编辑器编写的,但你可能理解这个想法)

public partial class ARInvoiceEntrySnrExt : PXGraphExtension<ARInvoiceEntry>
{
    public PXAction<ARInvoice> paySmartPanelAction
    [PXUIField(DisplayName = "Payment details", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
    public virtual IEnumerable PaySmartPanelAction(PXAdapter adapter)
    {
        WebDialogResult result = this.SmartPanelDataView.AskExt();
        if (result == WebDialogResult.OK)
            {
                var isValid = this.ValidateSmartPanelFields() //validation method everithing you may need
                if (isValid == false)
                {
                    throw new PXArgumentException(CstAPMessages.InvalidDetails, (Exception)null);
                }
        }
    }

    public virtual bool ValidateSmartPanelFields()
    {
        bool isValid = true;
        foreach (DataViewDetail detail in this.SmartPanelDataView.Select())
        {
            if (detail.FieldName <= 0)
            {
                cache.RaiseExceptionHandling<DataViewDetail.fieldName>(detail, detail.FieldName, new PXSetPropertyException(CstAPMessages.AmountPaidMustBeGreater));
                isValid = false;
            }
        }
        return isValid;
    }
}

推荐阅读