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.