在网格中选择一条线时的操作 [英] Action upon selecting a line in a grid

查看:84
本文介绍了在网格中选择一条线时的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在选择网格中的一行时启用或禁用按钮,这是我现在尝试的方法:

I'd like to enable or disable a button upon selecting a line in a grid, here's what I tried for now :

    public virtual void ARRegister_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        ARRegister row = e.Row as ARRegister;
        if (row == null) return;
        UnProcessLettering.SetEnabled(row.GetExtension<ARRegisterLeExt>().LettrageCD != null);
    }

我已经在网格中将同步设置为true.但是,当我选择LettrageCD不为null或为null的行时,没有任何改变.

And I've set the syncposition as true in my grid. But nothing changes when I select a row in which LettrageCD is not null or is null.

似乎我的问题是重复的:(突出显示行时触发了任何事件吗?(在我的第一次搜索中没有找到它:()

Edit : it seems my question is a duplicate : Is there any event triggered when highlighting a row? (didnt find it during my first search :( )

推荐答案

与其在PXAction上调用SetEnabled,请在按钮aspx声明上使用StateColumn属性.

Instead of calling SetEnabled on the PXAction, use the StateColumn property on your button aspx declaration.

声明按钮时,可以指定一个布尔DAC字段,该字段将基于按钮的值来启用/禁用该按钮.请注意,该按钮需要将DependOnGrid属性设置为网格的ID才能获取所选行:

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是一个自定义的未绑定布尔DAC字段:

IsButtonVisible is a custom unbound Boolean DAC field:

#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

您可以根据业务逻辑在RowSelected事件中设置IsButtonVisible的值:

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;
    }
}

来源: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆