在库存查询上添加属性字段 [英] Add Attributes fields on Inventory Lookup

查看:58
本文介绍了在库存查询上添加属性字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在销售订单和采购订单上添加用于库存查询的属性,有人知道如何做吗?或有什么想法?

解决方案

请参考下面的代码示例,以利用现成的<选择器和网格控制中的属性列 CRAttributesFieldAttribute



声明一个继承自<$的类 PXAddAtttributeColumns c $ c> CRAttributesFieldAttribute 。

 公共类PXAddAtttributeColumns:CRAttributesFieldAttribute 
{
string [] _names;
bool _IsForSelector;

public PXAddAtttributeColumns(string []名称,类型entityType,类型entityIDField,类型classIDField,布尔IsForSelector = true)
:base(entityType,entityIDField,classIDField)
{
_names =名称;
_IsForSelector = IsForSelector;
}

公共重写void CacheAttached(PXCache sender)
{
this._IsActive = true;
base.CacheAttached(sender);
}

受保护的覆盖无效AttributeFieldSelecting(PXCache发送者,PXFieldSelectingEventArgs e,PXFieldState状态,字符串attributeName,int idx)
{
if(_names.Any(attributeName。等于))
{
//即用的DisplayName前缀为 $ Attributes $--如果需要将其删除。
state.DisplayName =(!String.IsNullOrEmpty(state.DisplayName))? (state.DisplayName.Replace( $ Attributes $-,)):attributeName;
state.Visible = true;
//需要AutoGenerateColumns = AppendDynamic用于动态属性列创建的PXGrid控件
state.Visibility =(_IsForSelector)吗? PXUIVisibility.SelectorVisible:PXUIVisibility.Dynamic;
}
base.AttributeFieldSelecting(sender,e,state,attributeName,idx);
}

公共重写void CommandPreparing(PXCache sender,PXCommandPreparingEventArgs e)
{
base.CommandPreparing(sender,e);

if(e.BqlTable == null&& aggregateAttributes&& sender.GetItemType()。IsDefined(typeof(PXProjectionAttribute),true))
{
e.BqlTable = _BqlTable;
}
}
}

将属性作为列包含在库存查找,声明DAC扩展,如下所示:

 公共类InventoryItemPXExt:PXCacheExtension< PX.Objects.IN.InventoryItem> 
{
#region属性

公共抽象类属性:IBqlField {}

[PXAddAtttributeColumns(new [] { ASSETID, HWMODEL },
typeof(CSAnswerType.inventoryAnswerType),
typeof(InventoryItem.inventoryID),
typeof(InventoryItem.itemClassID))]
公共虚拟字符串[]属性{组; }

#endregion
}

字段将显示为下方:





可以在属性列上启用搜索通过将 FilterByAllFields 设置为 True





要在销售订单详细信息网格中将属性包括为列,请将DAC Extension声明为

 公共类SOLineExtension:PXCacheExtension< SOLine> 
{
公共抽象类itemAttributes:IBqlField {}

[PXAddAtttributeColumns(new [] { ASSETID, HWMODEL},
typeof(CSAnswerType.inventoryAnswerType ),
typeof(SOLine.inventoryID),
typeof(InventoryItem.itemClassID),​​false)]
公共虚拟字符串[] ItemAttributes {get;组; }
}

请确保指定 AutoGenerateColumns = AppendDynamic 用于 PXGrid 控制动态属性列的创建





字段将显示如下:





字段将显示如下:





注意:此示例适用于5.3系列– 5.30.1367及更高版本。


I want to add the attributes for my inventory lookup on Sales Order and Purchase Order, does anyone know how to? or any ideas?

解决方案

Please refer below code example to include Attributes Columns in Selector and Grid Control utilizing out-of-box CRAttributesFieldAttribute.

Declare a class PXAddAtttributeColumns inherited from 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;
        }
    }
}

To include attributes as Columns in Inventory Look up, declare DAC Extension as below:

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
}

Fields will show up as below:

Search can be Enabled on Attribute Columns by setting FilterByAllFields to True

To include attributes as Columns in Sales Order Details Grid, declare DAC Extension as below:

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; }
}

Make sure to specify AutoGenerateColumns="AppendDynamic" for PXGrid control dynamic Attribute columns creation

Fields will show up as below:

To include attributes as Columns in grid of Add Stock Item Dialog, declare DAC Extension as below:

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; }
}

Make sure to specify AutoGenerateColumns="AppendDynamic" for PXGrid control dynamic Attribute columns creation

Fields will show up as below:

Note: This example is applicable to 5.3 series – Build 5.30.1367 onwards.

这篇关于在库存查询上添加属性字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆