首页 > 解决方案 > 在选择器控制方面需要帮助

问题描述

我创建了一个选择器控件,它显示 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

解决方案


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

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

您可以执行以下操作来获取带有描述的查找:

  1. 创建如下表PXProjectionINItemLotSerialInventoryItem

    [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))]
    

结果,您将获得如下查找: 在此处输入图像描述


推荐阅读