在Inventory Lookup上添加属性字段

时间:2016-04-14 07:38:09

标签: acumatica

我想在销售订单和采购订单上添加库存查找的属性,有人知道怎么做?或任何想法?

1 个答案:

答案 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
}

字段将显示如下:

enter image description here

通过将FilterByAllFields设置为True

,可以在属性列上启用搜索

enter image description here

要将属性作为列包含在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

enter image description here

字段将显示如下:

enter image description here

要将属性作为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

enter image description here

字段将显示如下:

enter image description here

注意:此示例适用于5.3系列 - Build 5.30.1367以后。