Is there any event triggered when highlighting a row?

后端 未结 1 1264
时光说笑
时光说笑 2021-01-07 10:59

I created a ListView to show the list of documents, then created a button \"Button A\" to do some actions, my requirement is I would like the button status may be changed wi

相关标签:
1条回答
  • 2021-01-07 11:56

    To reduce callback to the server there isn't a row selected event. Instead there is PXToolbarButton StateColumn property to control the button enabled state.

    When you declare your button, you specify a Boolean DAC field that will enable/disable the button based on it's value. Note that the button needs the DependOnGrid property set to the ID of the grid to get the selected row:

    <px:PXToolBarButton Text="Button A" DependOnGrid="grid" StateColumn="IsButtonVisible">
    

    IsButtonVisible is a custom unbound Boolean DAC field (you may choose any name you want except isSelected/Selected which is reserved for checkbox):

    #region IsButtonVisible
    public abstract class isButtonVisible : IBqlField
    {
    }
    
    protected bool? _IsButtonVisible;
    [PXBool]
    [PXUIField(DisplayName = "Is Button Visible", Enabled = false, Visible = false)] 
    public virtual bool? IsButtonVisible
    {
        get
        {
            return _IsButtonVisible;
        }
        set
        {
            _IsButtonVisible = value;
        }
    }
    #endregion
    

    You can set the value of IsButtonVisible in the RowSelected event based on your business logic:

    protected virtual void DAC_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        DAC row = e.Row as DAC;
    
        if (row != null)
        {
            bool yourCondition = ???;
            row.IsButtonVisible = yourCondition;
        }
    }
    

    Source: Enable disable button of grid or PXToolBarButton, which depends from value of column in Acumatica

    0 讨论(0)
提交回复
热议问题