Skip to main content
Solved

Corrcetly disabling a custom action button

  • November 11, 2020
  • 3 replies
  • 1735 views

Forum|alt.badge.img
  • Jr Varsity III
  • 23 replies

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.

 

Best answer by Dhiren Chhapgar

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>

 

View original
Did this topic help you find an answer to your question?

3 replies

Dhiren Chhapgar
Community Manager
Forum|alt.badge.img
  • Director – Customization Services, Special Projects
  • 13 replies
  • Answer
  • November 12, 2020

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>

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 23 replies
  • November 16, 2020

That solved my problem, thanks!


arun83
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • 23 replies
  • October 11, 2024

Dear Team,

 

How to use multiple fields in StateColumn?

 

Thanks,

Arun


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings