【问题标题】:Acumatica - Cases Status ComboxboxAcumatica - 案例状态组合框
【发布时间】:2020-10-21 12:12:20
【问题描述】:

我们在使用自动化步骤的案例屏幕中向状态字段添加了一些额外的状态选项,这按预期工作。现在我们的要求是按字母顺序升序显示状态选项。有人可以建议我们如何实现这一目标。

我们在 Acumatica 2019 R2

 public class SelectableDataTypes : PXStringListAttribute
    {
        public string[] AllowedLabels = new string[]
        {
            "A","B","C"
        };

        public string[] AllowedValues = new string[]
        {
            "ValueA","ValueB","ValueC"            
        };
    }

    protected virtual void CRCase_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)
        {
            BaseEvent?.Invoke(sender, e);

            CRCase doc = e.Row as CRCase;

            if (doc == null)
                return;

            PXStringListAttribute.SetList<CRCase.status>(Base.Case.Cache, null, new SelectableDataTypes().AllowedValues, new SelectableDataTypes().AllowedLabels);
        }

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    我不确定是否有办法只是“排序”,但我从未尝试过这样做。另外值得注意的是,此方法需要对列表更改进行编程而不是使用自动化步骤,因此向列表中添加条目并不容易,但更可控。

    您可以按照您希望它们显示的顺序重新定义选项,这与我制作动态列表的顺序相同(如果这适合您的目的)。此示例假定您为每个标签和一个类定义了消息,其中每个值都定义在一个列表中。

    创建一个继承自 PXStringListAttribute 的类,并为 AllowedLabels 定义一个字符串数组,为 AllowedValues 定义一个字符串数组。包括您想要的选项,按您想要的顺序排序。对于这个例子,我们假设这是在一个名为 MySelectableData 的类中定义的。

    public class SelectableDataTypes : PXStringListAttribute
    {
    
        public string[] AllowedLabels = new string[]
        {
                Messages.FieldLabelA,
                Messages.FieldLabelB,
                Messages.FieldLabelC,
                Messages.FieldLabelD,
                Messages.FieldLabelE,
                Messages.FieldLabelF,
        };
    
        public string[] AllowedValues = new string[]
        {
                DataValues.ValueA,
                DataValues.ValueB,
                DataValues.ValueC,
                DataValues.ValueD,
                DataValues.ValueE,
                DataValues.ValueF,
        };
    }
    

    同样,由于您的目标是对所选内容进行排序,因此请务必按排序顺序列出它们。

    如果列表是动态的,请将以下内容(带有在列表之间更改的逻辑)放在 RowSelected 事件中。如果页面是静态的(在您描述的情况下更有可能),则将其放在页面的 Initialize 方法中。

    PXStringListAttribute.SetList<MyDAC.myField>(
        MyView.Cache,
        null,
        new MySelectableData.SelectableDataTypes().AllowedValues,
        new MySelectableData.SelectableDataTypes().AllowedLabels
    );
    

    PXStringListAttribute 上的 SetList 将允许您通过替换您的自定义选项来替换先前定义的选项来覆盖列表,如此处所示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多