Acumatica中如何让预填充库存字段仅显示InventoryID而非描述
Hey there! Let's break down how to configure your inventory fields in Acumatica to only display the InventoryID without the description, covering both standard system fields and your custom graph/projection scenario.
Standard Acumatica Inventory Fields (Non-Custom)
If you're working with out-of-the-box inventory fields, you have two straightforward approaches:
1. Modify the Field Attribute via Code
Use CacheAttached in your graph to adjust the StockItemAttribute to prioritize value-only display:
[PXMergeAttributes(Method = MergeMethod.Append)] [StockItem(SelectorMode = PXSelectorMode.DisplayModeValueOnly)] protected virtual void _(Events.CacheAttached<YourDAC.InventoryID> e) { }
This tells the selector to only show the InventoryID value in the field, while still keeping the description available for search suggestions if needed.
2. Adjust the ASPX Control Directly
If you prefer UI-level changes, edit the page's ASPX markup and set the selector's DisplayMode to Value:
<px:PXSelector ID="edInventoryID" runat="server" DataField="InventoryID" DisplayMode="Value" />
This overrides the attribute's settings for that specific control.
Custom Graph with PXProjection & PXSelectJoin
For your custom projection fields (KitComponentID and KitInventoryID), you can apply similar logic, either by updating the DAC attributes or using CacheAttached in your graph.
Option 1: Update the DAC Field Attributes
Modify the StockItemAttribute directly on your projection fields to enforce value-only display:
#region KitComponentID public abstract class kitComponentID : IBqlField { } [StockItem( DisplayName = "Kit Component ID", IsKey = true, BqlField = typeof(INKitSpecStkDet.compInventoryID), SelectorMode = PXSelectorMode.DisplayModeValueOnly)] public virtual int? KitComponentID { get; set; } #endregion #region KitInventoryID public abstract class kitInventoryID : IBqlField { } [StockItem( DisplayName = "Kit Inventory ID", IsKey = true, // Adjust based on your projection's requirements BqlField = typeof(YourSourceDAC.inventoryID), // Replace with your actual source field SelectorMode = PXSelectorMode.DisplayModeValueOnly)] public virtual int? KitInventoryID { get; set; } #endregion
The SelectorMode = PXSelectorMode.DisplayModeValueOnly flag ensures only the InventoryID is visible in the field.
Option 2: Use CacheAttached in Your Custom Graph
If you don't want to modify the projection's DAC directly, override the field attributes in your graph using CacheAttached:
public class YourCustomGraph : PXGraph<YourCustomGraph> { // Your existing PXSelectJoin query public PXSelectJoin<YourProjection, LeftJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<YourProjection.kitComponentID>>>, Where<...>> KitComponents; // Override KitComponentID display settings [PXMergeAttributes(Method = MergeMethod.Append)] [StockItem(SelectorMode = PXSelectorMode.DisplayModeValueOnly)] protected virtual void _(Events.CacheAttached<YourProjection.KitComponentID> e) { } // Override KitInventoryID display settings [PXMergeAttributes(Method = MergeMethod.Append)] [StockItem(SelectorMode = PXSelectorMode.DisplayModeValueOnly)] protected virtual void _(Events.CacheAttached<YourProjection.KitInventoryID> e) { } }
Option 3: Custom PXSelector for Full Control
If you need even more control (like explicitly defining which fields to display), replace the StockItemAttribute with a custom PXSelector:
#region KitComponentID public abstract class kitComponentID : IBqlField { } [PXSelector( typeof(InventoryItem.inventoryID), typeof(InventoryItem.inventoryID), // Only display this field DescriptionField = typeof(InventoryItem.descr), // Keep description for search functionality DisplayName = "Kit Component ID", IsKey = true)] [PXForeignReference(typeof(Field<KitComponentID>.IsRelatedTo<InventoryItem.inventoryID>))] public virtual int? KitComponentID { get; set; } #endregion
This gives you full control over what's shown in the selector dropdown and the field itself.
内容的提问来源于stack exchange,提问作者June B

