操作栏自定义项目的可见性

时间:2019-03-26 17:02:40

标签: acumatica

我在屏幕上定义了一个自定义对话框,在现有网格的“ ActionBar-CustomItems”中有一个按钮,该网格通过将“ PopupPanel”属性设置为对话框的“ ID”来打开该对话框。

有没有一种方法可以根据运行时条件来控制按钮的可见性?

具体来说,这是SOOrderEntry>“事务”网格“自定义项”中的一个按钮,用于打开包含与当前SOLine相关的自定义数据的对话框。如果是Base.IsTransferOrder,我想隐藏该按钮,因为它不适用。在图形扩展中没有定义任何自定义动作,只有自定义对话框中引用的视图。

页面扩展XML:

<Page path="~/pages/so/so301000.aspx" pageSource="...">
    <PXGrid ID="grid" ParentId="phG_tab_Items#0_grid" TypeFullName="PX.Web.UI.PXGrid">
        <Children Key="ActionBar.CustomItems">
            <AddItem>
                <PXToolBarButton TypeFullName="PX.Web.UI.PXToolBarButton">
                    <Prop Key="PopupPanel" Value="PanelCustomSOLineRelatedRecs" />
                    <Prop Key="Text" Value="Open Popup" />
                </PXToolBarButton>
            </AddItem>
        </Children>
    </PXGrid>

    <Content ID="cont3" ParentId="phG" TypeFullName="System.Web.UI.WebControls.Content">
        <Children Key="Controls">
            <AddItem>
                <PXSmartPanel TypeFullName="PX.Web.UI.PXSmartPanel">
                    <Prop Key="Virtual:ApplyStylesheetSkin" />
                    <Prop Key="ID" Value="PanelCustomSOLineRelatedRecs" />
                    <Prop Key="Caption" Value="Dialog with Line related Records" />
                    <Prop Key="Key" Value="CustomLineRecs" />
                    <Prop Key="CaptionVisible" Value="True" />
                    <Prop Key="LoadOnDemand" Value="True" />
                    <Prop Key="AutoCallBack.Enabled" Value="True" />
                    <Prop Key="AutoReload" Value="True" />
                    <Prop Key="AutoRepaint" Value="True" />
                    <Children Key="Controls">...</Children>
                </PXSmartPanel>
            </AddItem>
        </Children>
    </Content>
</Page>

更新:

即使PopupPanel属性仍可用于直接打开Dialog客户端,也必须在图形扩展中定义PXAction并将按钮绑定到该Action以控制可见性。

因此在图形扩展中定义操作

public PXAction<SOOrder> openCustomLineRecs;
[PXButton]
[PXUIField(DisplayName = "Open Popup")]
public virtual void OpenCustomLineRecs() { }

将PXToolBarButton绑定到Action,并指定CommandName,AutoCallBack.Command和AutoCallBack.Target将按钮绑定到Action

<PXToolBarButton TypeFullName="PX.Web.UI.PXToolBarButton">
    <Prop Key="Text" Value="Open Popup" />
    <Prop Key="PopupPanel" Value="PanelCustomSOLineRelatedRecs" />
    <Prop Key="CommandName" Value="openCustomLineRecs" />
    <Prop Key="AutoCallBack.Target" Value="ds" />
    <Prop Key="AutoCallBack.Command" Value="openCustomLineRecs" />
</PXToolBarButton>

可见性可以通过操作设置

protected virtual void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
    if (e.Row == null) return;
    this.openCustomLineRecs.SetVisible(!Base.IsTransferOrder);
}

1 个答案:

答案 0 :(得分:1)

尝试一下。

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

        SOOrder row = e.Row as SOOrder;

        if (row == null)
            return;

        if(row.OrderType == SOOrderTypeConstants.TransferOrder)            
            this.YOURBUTTONNAME.SetVisible(false);
        else
            this.YOURBUTTONNAME.SetVisible(true);
    }