带有扩展库的自定义按钮

Custom button with extension library

谁能帮我定制一个按钮。我已经添加了它,但它不起作用。我做错了什么?

  1. 我创建了一个自定义项目“测试”
  2. 使用以下代码添加了扩展库:
public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry>
    {
        public const string TestMsg = "Hello World";
        public static bool IsActive()
        {
            return true;
        }

        [PXUIField(DisplayName = "TestMethod")]
        [PXButton]
        public void TestMethod()
        {           
                throw new PXException(TestMsg);
        }
}
  1. 在屏幕上添加了一个按钮,并在我的测试方法 TestMethod 中添加了一个点击事件 See screenshot here
  1. 发布项目

也许有人可以分享一份详细且易于理解的手册,说明如何使用扩展库或 link 添加按钮到视频说明。我查看了 Aсumatiсa 文档 - 但显然我误解了它。

我怀疑您遇到的问题是缺少按钮的 PXAction 部分。看看这篇 Acumatica 帮助文章是否能帮助您找到正确的方向。 https://help-2021r1.acumatica.com/(W(7))/Help?ScreenId=ShowWiki&pageid=f1ef4253-f995-43f9-8c2e-86206d75c564

尝试将 PXAction 类型添加到您的扩展中,并将 IEnumerable 用于方法 return 类型。用于 PXAction 的类型将对应于屏幕的主要 DAC。

public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry>
{
    public static bool IsActive() => true;

    public const string TestMsg = "Hello World";

    public PXAction<PMProject> testMethod;

    [PXUIField(DisplayName = "TestMethod")]
    [PXButton]
    public virtual IEnumerable TestMethod(PXAdapter adapter)
    {
        throw new PXException(TestMsg);

        // used to return on standard Actions
        return adapter.Get();
    }
}

对于放置在表单上的按钮,我不确定,但我相信您应该扩展 AutoCallBack 部分并使用您的方法名称作为命令的值而不是使用单击 属性。您可能还需要将 AutoCallBack 目标值设置为 ds.