要在Acumatica中在同一DAC字段上切换选择器属性,可以按照以下步骤进行操作:
public abstract class myField : PX.Data.IBqlField
{
public class ListAttribute : PXStringListAttribute
{
public ListAttribute()
: base(new string[] { "Option1", "Option2" }, new string[] { "Option 1", "Option 2" })
{ }
}
[PXDBString(10)]
[PXUIField(DisplayName = "My Field")]
[List]
public virtual string MyField { get; set; }
}
public abstract class myField : PX.Data.IBqlField
{
public class ListAttribute : PXStringListAttribute
{
public ListAttribute()
: base(new string[] { "Option1", "Option2" }, new string[] { "Option 1", "Option 2" })
{ }
}
[PXDBString(10)]
[PXUIField(DisplayName = "My Field")]
[List]
public virtual string MyField { get; set; }
public abstract class useAlternateSelector : PX.Data.IBqlField
{
}
[PXDBBool]
[PXDefault(false)]
[PXUIField(DisplayName = "Use Alternate Selector")]
public virtual bool? UseAlternateSelector { get; set; }
}
protected virtual void _(Events.FieldSelecting e)
{
if (e.Row != null)
{
myDac row = (myDac)e.Row;
if (row.UseAlternateSelector == true)
{
PXSelectorAttribute.SetSelector(e.Cache, e.Row, typeof(AlternateSelector));
}
else
{
PXSelectorAttribute.SetSelector(e.Cache, e.Row, typeof(DefaultSelector));
}
}
}
上述代码示例在FieldSelecting事件中检查UseAlternateSelector属性的值,并根据需要切换选择器属性。
请注意,您需要根据实际情况修改代码示例中的DAC和选择器属性,并根据您自己的需求进行相应的更改。