Acumatica 有没有办法在代码中模拟网格的同步位置?

Acumatica 有没有办法在代码中模拟网格的同步位置?,acumatica,Acumatica,我需要在网格的当前选定行上执行操作。我可以通过将屏幕导入定制项目来实现这一点,但这是屏幕所需的唯一更改。为了让Acumatica尽可能保持原样,除非是绝对必要的,以便于新版本的升级,我试图避免将屏幕拉到定制项目中,只是为了在网格上启用同步 public class INSiteMaint_Extension : PXGraphExtension<INSiteMaint> { INLocation location; public override void Init

我需要在网格的当前选定行上执行操作。我可以通过将屏幕导入定制项目来实现这一点,但这是屏幕所需的唯一更改。为了让Acumatica尽可能保持原样,除非是绝对必要的,以便于新版本的升级,我试图避免将屏幕拉到定制项目中,只是为了在网格上启用同步

public class INSiteMaint_Extension : PXGraphExtension<INSiteMaint>
{
    INLocation location;

    public override void Initialize()
    {
        base.Initialize();
        Base.action.AddMenuAction(myAction);
    }

    protected void _(Events.RowSelected<INLocation> e)
    {
        INLocation row = e.Row;
        if (row?.LocationID != null)
        {
            location = row;
        }
    }


    #region Print Item Label
    public PXAction<INSite> myAction;
    [PXUIField(DisplayName = "My Action Label", MapEnableRights = PXCacheRights.Select)]
    [PXButton]
    protected virtual IEnumerable MyAction(PXAdapter adapter)
    {

        INSite site = Base.site.Current;
        if (location?.LocationID != null)
        {
        ...
我已经为INSiteMaint创建了一个图形扩展来添加我的操作按钮。我尝试创建一个内联对象,然后在Events.RowSelected事件处理程序中设置它。单击“我的操作”按钮时,对象似乎总是网格的第一行

public class INSiteMaint_Extension : PXGraphExtension<INSiteMaint>
{
    INLocation location;

    public override void Initialize()
    {
        base.Initialize();
        Base.action.AddMenuAction(myAction);
    }

    protected void _(Events.RowSelected<INLocation> e)
    {
        INLocation row = e.Row;
        if (row?.LocationID != null)
        {
            location = row;
        }
    }


    #region Print Item Label
    public PXAction<INSite> myAction;
    [PXUIField(DisplayName = "My Action Label", MapEnableRights = PXCacheRights.Select)]
    [PXButton]
    protected virtual IEnumerable MyAction(PXAdapter adapter)
    {

        INSite site = Base.site.Current;
        if (location?.LocationID != null)
        {
        ...
我还尝试创建INLocation视图,以在Events.RowSelected事件处理程序中设置Current。这不会产生任何编译错误,但在这种方法中屏幕不会完全加载。显然,这不是一种安全的方法

public class INSiteMaint_Extension : PXGraphExtension<INSiteMaint>
{
    public PXSelect<INLocation> loc;

    public override void Initialize()
    {
        base.Initialize();
        Base.action.AddMenuAction(myAction);
    }

    protected void _(Events.RowSelected<INLocation> e)
    {
        INLocation row = e.Row;
        if (row?.LocationID != null)
        {
            loc.Current = loc.Search<INLocation.locationID>(row.LocationID);
        }
    }


    #region Print Item Label
    public PXAction<INSite> myAction;
    [PXUIField(DisplayName = "My Action Label", MapEnableRights = PXCacheRights.Select)]
    [PXButton]
    protected virtual IEnumerable MyAction(PXAdapter adapter)
    {

        INSite site = Base.site.Current;
        INLocation location = loc.Current;

        if (location?.LocationID != null)
        {
        ...

我怀疑我的根本问题是,如果没有syncposition,就不会有回调来触发我的事件。我需要将此功能添加到几个屏幕上,而这一小改动似乎是将屏幕添加到定制项目中对于升级期间的可维护性来说是严重的过度使用。

我必须启动回调,这与您在另一个项目中尝试执行的操作非常类似。首先,在要同步位置的网格上,确保在px:PXGrid部分中设置SyncPosition=true集,然后将AutoCallback设置为针对要重新绘制的控件的ID,以便它们更新。以下是我的代码片段:

<px:PXGrid ID="gridShipmentLines" runat="server" DataSourceID="ds" Width="100%" SkinID="Details" SyncPosition="true" Height="100%" Style="left: 0px; top: 0px">                
    <AutoCallBack Target="fvLineDetail" Command="Refresh" ActiveBehavior="true">
        <Behavior RepaintControls="None" RepaintControlsIDs="gridShipmentLines,fvShipmentLineDetail,fvInventoryItem" />
    </AutoCallBack>
    <Levels>
        <px:PXGridLevel DataMember="HistoryDocLines">
我做了一个快速按钮作为测试动作,以获取当前HistoryDocLine以测试获取更新的行:

public PXAction<CYHistoryDoc> GetLine;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Get Line", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]        
protected virtual IEnumerable getLine(PXAdapter adapter)
{
    CYHistoryLine HL = HistoryDocLines.Current;            
    return adapter.Get();
}
我在函数的最后一行放置了一个断点,并且能够获得当前选择的HistoryLine。看看这是否有帮助