Solved

Corrcetly disabling a custom action button

  • 11 November 2020
  • 2 replies
  • 1546 views

Userlevel 2
Badge

I have a custom button on a grid and want it to be enabled only for certain rows.

Therefore I implment the RowSelected event and use SetDisabled(false).

That seems to have no effect. Pressing the button after selecting a row where the action should be disabled is still possible but causes an error message saying the button is disabled.

What do I have to do to get the button shown correctly as disabled?

 

Some Code:

ASPX:

<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
    <px:PXDataSource ID="ds" runat="server" … >
        <CallbackCommands>
                     <px:PXDSCallbackCommand Name="Discard" DependOnGrid="grid" >

<asp:Content ID="cont2" ContentPlaceHolderID="phL" runat="Server" RepaintOnDemand="false">

    <px:PXGrid ID="grid" runat="server" DataSourceID="ds" SkinID="Details" >

       <ActionBar >
            <CustomItems>
                <px:PXToolBarButton Text="Discard">
                    <AutoCallBack Command="Discard" Target="ds">
                        <Behavior CommitChanges="True" ></Behavior>
                                        </AutoCallBack>
                                </px:PXToolBarButton>
                         </CustomItems>
               </ActionBar>

Graph:

        public PXAction<EisDocumentEntry> Discard;
        [PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "Discard", Enabled = false)]
        protected virtual void discard(){ … }

        protected virtual void _(Events.RowSelected<EisDocumentEntry> e)

        {
            var row = e.Row;

            if(...)
            Discard.SetEnabled(false);

       }

 

I also tried with SetVisible(), which has either no effect.

 

icon

Best answer by Dhiren Chhapgar 12 November 2020, 04:34

View original

2 replies

Userlevel 2
Badge

That solved my problem, thanks!

Userlevel 2
Badge

To enable/disable Action tied to Grid’s Toolbar per highlighted row, you need to work with StateColumn property of PXToolBarButton. 

Below is aspx snip from out-of-box SO301000

<px:PXToolBarButton Text="Inventory Summary" DependOnGrid="grid" StateColumn="IsStockItem">
<AutoCallBack Command="InventorySummary" Target="ds" />
</px:PXToolBarButton>

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved