我想在销售订单和采购订单上添加库存查找的属性,有人知道怎么做?或任何想法?
答案 0 :(得分:4)
请参考下面的代码示例,使用开箱即用的CRAttributesFieldAttribute
在选择器和网格控件中包含属性列。
声明从PXAddAtttributeColumns
继承的课程CRAttributesFieldAttribute
。
public class PXAddAtttributeColumns : CRAttributesFieldAttribute
{
string[] _names;
bool _IsForSelector;
public PXAddAtttributeColumns(string[] names, Type entityType, Type entityIDField, Type classIDField, bool IsForSelector = true)
: base(entityType, entityIDField, classIDField)
{
_names = names;
_IsForSelector = IsForSelector;
}
public override void CacheAttached(PXCache sender)
{
this._IsActive = true;
base.CacheAttached(sender);
}
protected override void AttributeFieldSelecting(PXCache sender, PXFieldSelectingEventArgs e, PXFieldState state, string attributeName, int idx)
{
if (_names.Any(attributeName.Equals))
{
//Out-of-box DisplayName is prefixed with "$Attributes$-" - if you need to take that off.
state.DisplayName = (!String.IsNullOrEmpty(state.DisplayName)) ? (state.DisplayName.Replace("$Attributes$-", "")) : attributeName;
state.Visible = true;
//Requires AutoGenerateColumns="AppendDynamic" for PXGrid Control for dynamic Attribute columns creation
state.Visibility = (_IsForSelector) ? PXUIVisibility.SelectorVisible : PXUIVisibility.Dynamic;
}
base.AttributeFieldSelecting(sender, e, state, attributeName, idx);
}
public override void CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
{
base.CommandPreparing(sender, e);
if (e.BqlTable == null && aggregateAttributes && sender.GetItemType().IsDefined(typeof(PXProjectionAttribute), true))
{
e.BqlTable = _BqlTable;
}
}
}
要将属性作为列包含在Inventory Look up
中,请按以下方式声明DAC扩展名:
public class InventoryItemPXExt : PXCacheExtension<PX.Objects.IN.InventoryItem>
{
#region Attributes
public abstract class attributes : IBqlField { }
[PXAddAtttributeColumns(new[] { "ASSETID", "HWMODEL" },
typeof(CSAnswerType.inventoryAnswerType),
typeof(InventoryItem.inventoryID),
typeof(InventoryItem.itemClassID))]
public virtual string[] Attributes { get; set; }
#endregion
}
字段将显示如下:
通过将FilterByAllFields
设置为True
要将属性作为列包含在Sales Order Details Grid
中,请按以下方式声明DAC扩展名:
public class SOLineExtension : PXCacheExtension<SOLine>
{
public abstract class itemAttributes : IBqlField { }
[PXAddAtttributeColumns(new[] { "ASSETID", "HWMODEL" },
typeof(CSAnswerType.inventoryAnswerType),
typeof(SOLine.inventoryID),
typeof(InventoryItem.itemClassID), false)]
public virtual string[] ItemAttributes { get; set; }
}
确保为AutoGenerateColumns="AppendDynamic"
控件动态属性列创建
PXGrid
字段将显示如下:
要将属性作为Add Stock Item
对话框的网格中的列包含,请按以下方式声明DAC扩展:
public class SOSiteStatusSelectedExtension : PXCacheExtension<SOSiteStatusSelected>
{
public abstract class itemAttributes : IBqlField { }
[PXAddAtttributeColumns(new[] { "ASSETID", "HWMODEL" },
typeof(CSAnswerType.inventoryAnswerType),
typeof(InventoryItem.inventoryID),
typeof(InventoryItem.itemClassID), false)]
public virtual string[] ItemAttributes { get; set; }
}
确保为AutoGenerateColumns="AppendDynamic"
控件动态属性列创建
PXGrid
字段将显示如下:
注意:此示例适用于5.3系列 - Build 5.30.1367以后。