acumatica - 在选择器控制方面需要帮助
问题描述
我创建了一个选择器控件,它显示 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))]
解决方案
属性的主要问题DescriptionField
是它正在等待从为其Selector
写入的同一个表中获取字段。但是在ID/CD的情况下,CD通常不存在于存在ID的表中,除了主表。
更新我已经删除了以前的代码(使用自定义属性和 FieldSelecting 事件处理程序的实现),因为它带来了性能问题。下面的代码使用相同的查找结果,但使用一个内部连接获取数据,而不是之前代码正在执行的所有请求。
您可以执行以下操作来获取带有描述的查找:
创建如下表
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 { } }
将您的选择器设置为使用
PXProjection
如下:[PXSelector(typeof(Search<INItemLotSerialWithInventoryItem.lotSerialNbr>), new Type[] { typeof(INItemLotSerialWithInventoryItem.lotSerialNbr) }, SubstituteKey = typeof(INItemLotSerialWithInventoryItem.lotSerialNbr), DescriptionField = typeof(INItemLotSerialWithInventoryItem.inventoryCD))]
推荐阅读
- python - 定义一个函数并将其用于python中的多个文件或模块
- lodash - Lodash 创建自定义函数的方式
- php - 数据库未连接到生产环境
- python - 获取列中某个唯一值的数量
- matlab - 使用当前时间保存工作区。MATLAB
- .htaccess - htaccess中的重写和重定向url问题
- java - Hive 选择问题:java.lang.IncompatibleClassChangeError
- visual-studio - 替换 Visual Studio 菜单中的默认移动键
- c++ - 此序列背后的逻辑已构建,但出现问题?
- java - 自定义溢出菜单在 android API 21 和 23+ 中不会给出相同的结果