【问题标题】:Get combination of CD and description for PXSelector获取 PXSelector 的 CD 和描述组合
【发布时间】:2017-01-17 21:55:18
【问题描述】:

我正在尝试使用选择器来查找客户,我希望它显示 CD 以及字段中的描述。我在 Acumatica 中见过很多次 - 我以为我知道该怎么做,但它不起作用。这是我的代码:

     #region CustomerLookup
     public abstract class customerLookup : PX.Data.IBqlField
     {
     }
     protected string _CustomerLookup;
     [PXDBString(100, IsUnicode = true)]
     [PXUIField(DisplayName = "Customer Lookup")]
     [PXSelector(typeof(Customer.acctCD)
                ,typeof(Customer.acctCD)
                ,typeof(Customer.acctName)
                ,DescriptionField=typeof(Customer.acctName))]
     public virtual string CustomerLookup
     {
         get
         {
             return this._CustomerLookup;
         }
         set
         {
             this._CustomerLookup = value;
         }
     }
     #endregion

我原以为提供 DescriptionField 会解决这个问题,但事实并非如此。

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    在回答问题之前,我先提一下上面代码sn-p的2大问题:

    1. 在 Acumatica 中,Customers 是一种特定的系统对象类型,它支持分段键。要创建支持分段键的记录查找,您应该使用PXDimensionSelectorAttribute 而不是PXSelectorAttribute。对于客户实体,有几个开箱即用的属性,例如 CustomerAttribute 或 CustomerActiveAttribute,您可以使用它们来创建客户查找:

    2. CustomerLookup 字段必须是 Int32? (int?) 类型:在 Acumatica 中,用户可以随时间更改客户 ID(通过 Change ID 客户屏幕上的按钮)。要为客户 DAC 建立外键,更好的方法是声明一个整数字段并通过 Customer.BAccount 字段将您的自定义记录与客户相关联

    以下是 DAC 字段的推荐声明,它在 UI 中创建客户查找:

    [Serializable]
    public partial class DetailsResult : IBqlTable
    {
        ...
    
        #region CustomerId
        public abstract class customerId : PX.Data.IBqlField
        {
        }
        [Customer(DescriptionField = typeof(Customer.acctName))]
        public virtual Int32? CustomerID { get; set; }
        #endregion
    
        ...
    }
    

    指定 DescriptionField 属性后,PXDimensionSelector 放置在表单上将默认根据“{SearchKey/SubstituteKey} - {DescriptionField}”模式格式化所选记录:

    要在网格单元格中显示 DescriptionField,您必须为 CustomerID_description 字段定义附加列(其中 _description 部分是 Acumatica 的特殊关键字,专门用于此类请求):

    【讨论】:

    • 将您的示例用于 DAC 中的 CustomerID 字段,[Customer] 和 [CustomerActive] 在设计模式下刷新时都会在我的 aspx 页面上创建错误 - 就好像它们在某种程度上不是有效的选择器一样。我已经尝试使用“substitutekey”参数创建标准 ID 类型选择器,并且效果很好 - 除了“描述”字段仍然没有按我想要的方式显示。目前不知道如何进行。
    • 我想我现在唯一要提出的其他选择是提交支持案例,这样我们就可以审查您的项目并找出根本原因。
    【解决方案2】:

    我相信答案是显而易见的 - 我认为描述字段在网格中的工作方式不同。在标题字段中,它可以在您离开 CD 时显示 CD - 描述。网格字段显然不是这样工作的,即使您在选择器中指定描述字段的方式与在标题选择器中的方式一样。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-01
      • 2020-07-02
      • 2021-12-09
      • 2015-07-29
      • 1970-01-01
      • 1970-01-01
      • 2018-05-01
      相关资源
      最近更新 更多