如何基于表单字段动态过滤PXSelect属性

时间:2019-05-03 15:06:20

标签: dynamic filter acumatica

如果选择了PONumber,我想过滤相关的POReceipts。如果未选择PONumber,我想显示所有POReceipts。

一个POOrder有很多POReceipts

在我的图中,我有以下内容

数据源

public PXSelect<MYGRPH> Document;

我希望以下属性能够根据采购订单编号进行动态过滤。...

public PXSelect<POReceipt, Where<POReceit.status, Equal<POStatus.open>>> Receipts]

如果填写了采购订单编号,如何动态过滤“收据”以添加以下子句?

Where<POReceipt.orderNbr, Equal<Current<MYGRAPH.orderNbr>>>  ??

是否可以动态添加限制器?

1 个答案:

答案 0 :(得分:0)

查看POOrder:

PXSelect<POOrder> Document;

在表单中为POOrder键字段添加控件:

<px:PXDropDown CommitChanges="True" ID="edOrderType" runat="server" AllowNull="False" DataField="OrderType" SelectedIndex="2" />
<px:PXSelector CommitChanges="True" ID="edOrderNbr" runat="server" DataField="OrderNbr" AutoRefresh="True" />

当用户在表单控件中选择POOrder键字段时,它将设置当前的POOrder缓存对象,您可以使用该对象过滤其他视图:

public PXSelectJoin<POReceipt,
       LeftJoin<POOrderReceipt, On<POReceipt.receiptNbr, Equal<POOrderReceipt.receiptNbr>>>, 
       Where<POOrderReceipt.pOType, Equal<Current<POOrder.orderType>>, 
       And<POOrderReceipt.pONbr, Equal<Current<POOrder.orderNbr>>>>> Receipts;

编辑:

  

问题在于,POOrder字段将不会总是被填写   首先。

Brendan在评论中建议的添加或子句:

public PXSelectJoin<POReceipt,
       LeftJoin<POOrderReceipt, On<POReceipt.receiptNbr, Equal<POOrderReceipt.receiptNbr>>>,
       Where<Where2<Where<Current<POOrder.orderType>, IsNull,
                    Or<Current<POOrder.orderType>, Equal<POOrderReceipt.pOType>>>,
       And<Where2<Where<Current<POOrderReceipt.pONbr>, IsNull>,
                  Or<Current<POOrderReceipt.pONbr>, Equal<POOrder.orderNbr>>>>>>> Receipts;