Reputation: 804
I have a custom Dialog defined in a Screen and a Button in the "ActionBar-CustomItems" of an existing Grid that opens that dialog by setting the "PopupPanel" property to the "ID" of the dialog.
Is there a way to control the Visibility of the button based on run-time conditions?
Specifically it's a button in the SOOrderEntry > Transactions grid Custom Items that opens the dialog with custom data related to the current SOLine. If Base.IsTransferOrder I want to hide the button as it is not applicable. There are no custom Actions defined in the graph Extension -- only the View that is referenced within the custom Dialog.
The page extension 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>
Update:
It was necessary to define a PXAction in the graph extension and bind the button to that Action to control the visibility even though the PopupPanel property could still be used to directly open the Dialog client-side.
So in the graph extension define the Action
public PXAction<SOOrder> openCustomLineRecs;
[PXButton]
[PXUIField(DisplayName = "Open Popup")]
public virtual void OpenCustomLineRecs() { }
Bind the PXToolBarButton to the Action specifying the CommandName, AutoCallBack.Command and AutoCallBack.Target to bind the button to the 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>
The Visibility could be set through the Action
protected virtual void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
if (e.Row == null) return;
this.openCustomLineRecs.SetVisible(!Base.IsTransferOrder);
}
Upvotes: 0
Views: 401
Reputation: 773
Try this.
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);
}
Upvotes: 1