我需要对当前选定的网格行执行操作。我可以通过将屏幕导入自定义项目来完成此操作,但这是屏幕所需的唯一更改。除非绝对必要(为了更容易升级新版本),否则希望尽可能多地保留Acumatica,我试图避免将屏幕拉入自定义项目,只是为了在网格上启用同步。
我已经为INSiteMaint创建了一个图形扩展来添加我的动作按钮。我试图创建一个INLocation对象,然后在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)
{
...
我怀疑我的根本问题是没有同步,没有回调来触发我的事件。我需要将这个功能添加到多个屏幕,这一个小的改变似乎是在定制项目中添加屏幕对于升级期间的可维护性而言严重过度。
我不得不发起回调非常类似于你在另一个项目中尝试做的事情。首先,在您希望位置同步的网格上,确保在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。看看是否有帮助。