【问题标题】:Visibility of Action Bar Custom Item操作栏自定义项的可见性
【发布时间】:2019-03-28 22:31:40
【问题描述】:

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

有没有办法根据运行时条件控制按钮的可见性?

具体来说,它是 SOOrderEntry > Transactions 网格 Custom Items 中的一个按钮,用于打开包含与当前 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>

更新:

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

所以在图形扩展中定义动作

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

将 PXToolBarButton 绑定到指定 CommandName、AutoCallBack.Command 和 AutoCallBack.Target 的操作,以将按钮绑定到操作

<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>

可见性可以通过Action设置

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

【问题讨论】:

    标签: acumatica


    【解决方案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);
        }
    

    【讨论】:

    • 这里的问题是该按钮没有在任何地方的服务器端代码/图形扩展中定义——仅在 ASPX 页面中。我必须定义动作,将按钮绑定到该动作,然后才能控制可见性。我已经用最终解决方案更新了原始问题以供参考。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 2012-08-10
    • 1970-01-01
    相关资源
    最近更新 更多