选择器控件显示错误的列值

问题描述 投票:0回答:1

我创建了一个选择器控件,它显示 INItemLotSerial 表中所有序列号的列表,并且它工作正常。问题是描述字段显示InventoryID,如何显示InventoryCD。这是我的示例代码:

[PXSelector(typeof(Search<INItemLotSerial.lotSerialNbr>),
    new Type[] { typeof(INItemLotSerial.lotSerialNbr), typeof(INItemLotSerial.inventoryID) },
    SubstituteKey = typeof(INItemLotSerial.lotSerialNbr), DescriptionField = typeof(INItemLotSerial.inventoryID))]

我也加入了 InventoryItem 但这不起作用。

[PXSelector(typeof(Search2<INItemLotSerial.lotSerialNbr,
        LeftJoinSingleTable<InventoryItem, On<InventoryItem.inventoryID,Equal<INItemLotSerial.inventoryID>>>>),
    new Type[] { typeof(INItemLotSerial.lotSerialNbr), typeof(INItemLotSerial.inventoryID) },
    SubstituteKey = typeof(INItemLotSerial.lotSerialNbr), DescriptionField = typeof(InventoryItem.inventoryCD))]

acumatica
1个回答
2
投票

DescriptionField
属性的主要问题是它正在等待从写入
Selector
的同一个表中获取字段。但通常在 ID/CD 的情况下,除了主表之外,ID 存在的表中不存在 CD。

更新我删除了以前的代码(使用自定义属性和 FieldSelecting 事件处理程序实现),因为它带来了性能问题。下面的代码产生相同的查找,但通过一个内部联接获取数据,而不是前面的代码正在执行的所有请求。

您可以执行以下操作来获取此查找及其描述:

  1. PXProjection
    INItemLotSerial
    表上创建
    InventoryItem
    ,如下所示:

    [PXCacheName("Lot Serials with Inventory CD")]
    [PXProjection(typeof(Select2<INItemLotSerial,
        InnerJoin<InventoryItem,
                On<INItemLotSerial.inventoryID, Equal<InventoryItem.inventoryID>>>>))]
    public class INItemLotSerialWithInventoryItem : IBqlTable
    {
        [PXDBInt(BqlField = typeof(INItemLotSerial.inventoryID))]
        [PXUIField(DisplayName = "Inventory ID", Visibility = PXUIVisibility.Visible, Visible = false)]
        public virtual int? InventoryID { get; set; }
    
        public abstract class inventoryID : IBqlField { }
    
        [PXDBString(InputMask = "", IsUnicode = true, BqlField = typeof(InventoryItem.inventoryCD))]
        [PXUIField(DisplayName = "Inventory ID")]
        public virtual string InventoryCD { get; set; }
        public abstract class inventoryCD : IBqlField { }
    
        [PXDBString(InputMask = "", IsUnicode = true, BqlField = typeof(INItemLotSerial.lotSerialNbr))]
        [PXUIField(DisplayName = "Lot/Serial Nbr")]
        public virtual string LotSerialNbr { get; set; }
        public abstract class lotSerialNbr : IBqlField { }
    }
    
  2. 设置您的选择器以使用此

    PXProjection
    ,如下所示:

    [PXSelector(typeof(Search<INItemLotSerialWithInventoryItem.lotSerialNbr>),
    new Type[] { typeof(INItemLotSerialWithInventoryItem.lotSerialNbr) }, 
        SubstituteKey = typeof(INItemLotSerialWithInventoryItem.lotSerialNbr), 
        DescriptionField = typeof(INItemLotSerialWithInventoryItem.inventoryCD))]
    

结果,您将得到如下查找:

© www.soinside.com 2019 - 2024. All rights reserved.