Is there any event triggered when highlighting a row?

冷暖自知 提交于 2019-12-01 12:23: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 with the selected document changes.

Fox example: there are three documents in the following graphic, I want the button is enabled when I click Order-00001 or Order-00002, and it is disabled for Order-00003 due to no money in it.

I appreciate if you could give me a hint if there is any event to be raised when I click a row. Thanks a lot.


回答1:


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



来源:https://stackoverflow.com/questions/47877150/is-there-any-event-triggered-when-highlighting-a-row

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!