【问题标题】:Custom button with extension library带有扩展库的自定义按钮
【发布时间】:2021-07-10 11:30:57
【问题描述】:

任何人都可以帮助我使用自定义按钮。我已经添加了它,但它不起作用。我做错了什么?

  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. 发布项目

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

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    尝试将 PXAction 类型添加到您的扩展中,并使用 IEnumerable 作为方法返回类型。用于 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 部分并使用您的方法名称作为 Command 属性的值,而不是使用 click。您可能还需要将 AutoCallBack 目标值设置为 ds。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 我查看了这篇文章,但我无法确定哪个实体用于 PXAction,当我尝试使用类型为 ProjectEntry 的 PXAction 时出现错误:" 'PX.Objects.PM.ProjectEntry'不能用作泛型类型或方法“PXAction”中的类型参数“TNode”。没有从“PX.Objects.PM.ProjectEntry”到“PX.Data.IBqlTable”的隐式引用转换”public PXAction测试; [PXUIField(DisplayName = "Test")] [PXButton] public void test() { ...
      • 我尝试使用“PMProject”:public PXAction Test;但这对我没有帮助:(我觉得这很容易,但无法理解它是如何工作的
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-26
      • 2020-03-19
      相关资源
      最近更新 更多