Acumatica动态下拉菜单 [英] Acumatica dynamic dropdown

查看:94
本文介绍了Acumatica动态下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Grid中有一个下拉菜单,我想在运行时填充它。我在RowSelected事件中尝试过,但无法正常工作。

I have a dropdown in a Grid and I want to fill it in runtime. I tried it in a RowSelected event but it doesn't work.

然后我尝试使用它在DAC的字段定义中分配属性PXStringList,但它也不起作用。

Then I tried it to assign the attribute PXStringList in the field definition on the DAC, but it doesn't work either.

这是事件

        protected virtual void HIASetupDetail_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        List<string> values = new List<string>();
        values.AddRange(new string[] { "A", "B" });

        if (e.Row == null)
        {
            return;
        }

        HIASetupDetail HIASetupDetailRow = (HIASetupDetail)e.Row;

        PXStringListAttribute.SetList<HIASetupDetail.acumaticaField>(sender, HIASetupDetailRow, values.ToArray(), values.ToArray());
    }

这是DAC

[System.SerializableAttribute()]
public class HIASetupDetail : PX.Data.IBqlTable
{        
    #region AcumaticaField
    public abstract class acumaticaField : PX.Data.IBqlField
    {
    }
    [PXDBString()]
    [PXDefault()]
    [PXUIField(DisplayName = "Acumatica Field")]
    public virtual string AcumaticaField { get; set; }
    #endregion


}

此网格中的下拉列表是什么

This is the Dropdown in the Grid

有人知道为什么它在网格中不起作用吗?

Any idea why it doesn't work in the Grid?

推荐答案

下面是示例,您可以在选择该字段时更改 PXStringListAttribute 的值:

Here is example how you can change the Values of the PXStringListAttribute while selecting that field:

DAC扩展

public class SOOrderExt:PXCacheExtension<SOOrder>
{

    #region TestField
    [PXString]
    [PXStringList()]
    [PXUIField(DisplayName = "Acumatica Field")]
    public string TestField { get; set; }

    public abstract class testField : IBqlField { }
    #endregion
}

图形扩展

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    public virtual void SOOrder_TestField_FieldSelecting(PXCache sender,PXFieldSelectingEventArgs e)
    {
        if(e.Row!=null)
        {
            List<string> values = new List<string>();
            values.AddRange(new []{ "First","Second"});
            SOOrder row = (SOOrder)e.Row;
            PXStringListAttribute.SetList<SOOrderExt.testField>(sender, row, values.ToArray(), values.ToArray());
        }
    }
}

另外,您应该确保当您从布局编辑器将字段添加到页面时,该字段被添加为组合框

Also you should be sure that when you added the field to the Page from Layout Editor that it was added as "Combobox"

结果是:

更新1
要更改网格中的下拉菜单,可以使用以下代码作为示例:

UPDATE 1 For changing the dropdown in the Grid you can use the following code as an example:

图形扩展

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    public virtual void SOLine_TestField_FieldSelecting(PXCache sender,PXFieldSelectingEventArgs e)
    {
        if(e.Row!=null)
        {
            List<string> values = new List<string>();
            values.AddRange(new[] { "First", "Second" });
            PXStringListAttribute.SetList<SOLineExt.testField>(sender, null, values.ToArray(), values.ToArray());
        }
    }
}

DAC扩展

public class SOLineExt : PXCacheExtension<SOLine>
{

    #region TestField
    [PXString]
    [PXStringList()]
    [PXUIField(DisplayName = "Acumatica Field")]
    public string TestField { get; set; }

    public abstract class testField : IBqlField { }
    #endregion
}

如您所见,区别在于在调用 PXStringListAttribute.SetList< T> 的情况下,仅在传递<$时有效c $ c> null 作为行,以便对所有行进行更改。

As you can see the difference is in the call of the PXStringListAttribute.SetList<T> in case of grid this is working only when passing null as row so that the change will be done for all lines.

这篇关于Acumatica动态下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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