无法在GL404000屏幕上触发fieldupdated或rowupdated事件

时间:2018-10-05 15:54:38

标签: acumatica

我正在尝试扩展AccountByPeriodEnq业务逻辑,但是我面临以下问题:

我似乎无法触发GLTranR_RowUpdated或GLTranR_Selected_FieldUpdated事件。 (除非我单击刷新按钮,否则将触发事件)

这是我的代码:

  #region EventHandler
        protected void GLTranR_Selected_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated del)
        {
            del?.Invoke(cache, e);
            var row = (GLTranR)e.Row;
        }

        protected void GLTranR_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
        {
            var row = (GLTranR)e.Row;
        }

        #endregion 

当我在这些方法中的任何一个上设置断点时,它实际上并没有中断。

似乎也从未触发过原始事件(位于AccountByPeriodEnq.cs图中),因为我从未看到“重新分类”按钮被禁用。

protected virtual void GLTranR_Selected_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            reclassify.SetEnabled(GetSelectedTrans().Any());
        }

我已经检查了aspx,并为“选定”字段设置了commitchanges = true。

这是aspx:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/FormDetail.master" AutoEventWireup="true"
  ValidateRequest="false" CodeFile="GL404000.aspx.cs" Inherits="Page_GL404000"
  Title="Untitled Page" %>

<%@ MasterType VirtualPath="~/MasterPages/FormDetail.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phDS" runat="Server">
  <px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" TypeName="PX.Objects.GL.AccountByPeriodEnq"
    PrimaryView="Filter" PageLoadBehavior="PopulateSavedValues">
    <CallbackCommands>
      <px:PXDSCallbackCommand CommitChanges="True" Name="previousperiod" HideText="True"/>
      <px:PXDSCallbackCommand CommitChanges="True" Name="nextperiod" HideText="True"/>
      <px:PXDSCallbackCommand DependOnGrid="grid" Name="Reclassify" CommitChanges="True"/>
      <px:PXDSCallbackCommand DependOnGrid="grid" Name="ReclassifyAll"/>
      <px:PXDSCallbackCommand DependOnGrid="grid" Name="ReclassificationHistory" StateColumn="IncludedInReclassHistory"/>
    </CallbackCommands>
  </px:PXDataSource>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phF" runat="Server">
  <px:PXFormView ID="form" runat="server"   Width="100%"
    Caption="Selection" DataMember="Filter" DefaultControlID="edFinPeriodID" DataSourceID="ds" TabIndex="100">
    <Template>
      <px:PXLayoutRule runat="server" StartColumn="True" LabelsWidth="SM" ControlSize="M" ></px:PXLayoutRule>
      <px:PXSelector CommitChanges="True" ID="edOrganizationID" runat="server" DataField="OrganizationID"></px:PXSelector>
      <px:PXSegmentMask CommitChanges="True" ID="edBranchID" runat="server" DataField="BranchID" Autorefresh="true"></px:PXSegmentMask>
      <px:PXSelector CommitChanges="True" ID="edLedgerID" runat="server" DataField="LedgerID" Autorefresh="true"></px:PXSelector>
      <px:PXSelector CommitChanges="True" ID="edStartPeriodID" runat="server" DataField="StartPeriodID"></px:PXSelector>
      <px:PXSelector CommitChanges="True" ID="edEndPeriodID" runat="server" DataField="EndPeriodID" Autorefresh="True"></px:PXSelector>
      <px:PXSegmentMask CommitChanges="True" ID="edAccountID" runat="server" DataField="AccountID"></px:PXSegmentMask>
      <px:PXSegmentMask CommitChanges="True" ID="edSubID" runat="server" DataField="SubID" SelectMode="Segment"  ></px:PXSegmentMask>
      <px:PXLayoutRule runat="server" StartColumn="True" LabelsWidth="SM" ControlSize="S" ></px:PXLayoutRule>
      <px:PXDateTimeEdit CommitChanges="True" ID="edStartDateUI" runat="server" DataField="StartDateUI" ></px:PXDateTimeEdit>
      <px:PXDateTimeEdit CommitChanges="True" ID="edPeriodStartDate" runat="server" DataField="PeriodStartDateUI" ></px:PXDateTimeEdit>
      <px:PXDateTimeEdit CommitChanges="True" ID="edEndDateUI" runat="server" DataField="EndDateUI" ></px:PXDateTimeEdit>
      <px:PXDateTimeEdit CommitChanges="True" ID="edPeriodEndDateUI" runat="server" DataField="PeriodEndDateUI" ></px:PXDateTimeEdit>
      <px:PXNumberEdit runat="server" ID="CstPXNumberEdit1" DataField="UsrCreditTotal" CommitChanges="True" />
      <px:PXNumberEdit runat="server" ID="CstPXNumberEdit2" DataField="UsrDebitTotal" CommitChanges="True" />
      <px:PXNumberEdit runat="server" ID="CstPXNumberEdit14" DataField="UsrSolde" CommitChanges="True" />
      <px:PXLayoutRule runat="server" StartColumn="True" SuppressLabel="True" ></px:PXLayoutRule>
      <px:PXCheckBox CommitChanges="True" ID="chkShowSummary" runat="server" DataField="ShowSummary" ></px:PXCheckBox>
      <px:PXCheckBox CommitChanges="True" ID="chkIncludeUnposted" runat="server" DataField="IncludeUnposted" ></px:PXCheckBox>
      <px:PXCheckBox CommitChanges="True" ID="chkIncludeUnreleased" runat="server" DataField="IncludeUnreleased" ></px:PXCheckBox>
      <px:PXCheckBox CommitChanges="True" ID="chkIncludeReclassified" runat="server" DataField="IncludeReclassified" ></px:PXCheckBox>
      <px:PXCheckBox CommitChanges="True" ID="chkShowCuryDetail" runat="server" DataField="ShowCuryDetail" ></px:PXCheckBox>

      <px:PXLayoutRule runat="server" StartColumn="True">
      </px:PXLayoutRule>
      <px:PXNumberEdit ID="edBegBal" runat="server" DataField="BegBal">
      </px:PXNumberEdit>
      <px:PXNumberEdit ID="edTurnOver" runat="server" DataField="TurnOver">
      </px:PXNumberEdit>
      <px:PXNumberEdit ID="edEndBal" runat="server" DataField="EndBal">
      </px:PXNumberEdit>
      <px:PXGroupBox runat="server" ID="groupAffichage" Caption="Afficher" CommitChanges="True" DataField="UsrAffichage" RenderSimple="True" RenderStyle="RoundBorder">
        <ContentLayout Layout="Stack" />
        <Template>
          <px:PXRadioButton runat="server" ID="CstRadioButton15" Text="Tous" Value="0" Checked="False" GroupName="groupAffichage" />
          <px:PXRadioButton runat="server" ID="CstRadioButton16" Value="1" Text="Lettres" GroupName="groupAffichage" Checked="False" />
          <px:PXRadioButton runat="server" ID="CstRadioButton17" GroupName="groupAffichage" Value="2" Text="Non lettres" Checked="True" /></Template></px:PXGroupBox></Template>
  </px:PXFormView></asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="phG" runat="Server">
  <px:PXGrid ID="grid" runat="server"  Height="150px" 
    Width="100%" AllowPaging="True" AdjustPageSize="Auto" Caption="Summary By Period" SyncPosition ="True" FastFilterFields="TranDesc,RefNbr,"
    BatchUpdate="True" AllowSearch="True" SkinID="PrimaryInquire" RestrictFields="True" DataSourceID="ds" TabIndex="100" PreserveSortsAndFilters="False">
    <CallbackCommands>
      <Refresh RepaintControlsIDs="form"/>
    </CallbackCommands>
    <AutoSize Container="Window" Enabled="True" />
    <Mode AllowAddNew="False" AllowDelete="False"  />
    <Levels>
      <px:PXGridLevel DataMember="GLTranEnq">
        <Columns>
          <px:PXGridColumn DataField="Selected" TextAlign="Center" Type="CheckBox" Width="30px" AllowCheckAll="True" AllowShowHide="Server" CommitChanges="True"></px:PXGridColumn>
          <px:PXGridColumn DataField="Module" Width="100px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="BatchNbr" Width="100px" LinkCommand="ViewBatch" ></px:PXGridColumn>
          <px:PXGridColumn DataField="TranDate" Width="100px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="FinPeriodID" Width="100px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="TranDesc" Width="224px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="RefNbr" Width="100px" LinkCommand="ViewDocument" ></px:PXGridColumn>
          <px:PXGridColumn DataField="LineNbr" TextAlign="Right" Width="100px"  ></px:PXGridColumn>
          <px:PXGridColumn DataField="BranchID" Width="100px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="AccountID" Width="108px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="SubID" Width="198px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="SignBegBalance" TextAlign="Right" Width="100px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="DebitAmt" TextAlign="Right" Width="100px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="CreditAmt" TextAlign="Right" Width="100px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="SignEndBalance" TextAlign="Right" MatrixMode="True" Width="100px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="CuryID"  AllowShowHide="Server" ></px:PXGridColumn>
          <px:PXGridColumn DataField="SignCuryBegBalance" TextAlign="Right" Width="100px" AllowShowHide="Server" ></px:PXGridColumn>
          <px:PXGridColumn DataField="CuryDebitAmt" TextAlign="Right" Width="100px" AllowShowHide="Server" ></px:PXGridColumn>
          <px:PXGridColumn DataField="CuryCreditAmt" TextAlign="Right" Width="100px" AllowShowHide="Server" ></px:PXGridColumn>
          <px:PXGridColumn DataField="SignCuryEndBalance" TextAlign="Right" Width="100px" AllowShowHide="Server" ></px:PXGridColumn>
          <px:PXGridColumn DataField="InventoryID" Width="120px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="ReferenceID" Width="120px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="ReferenceID_BaccountR_AcctName" Width="200px" ></px:PXGridColumn>
          <px:PXGridColumn DataField="ReclassBatchNbr" TextAlign="Right" Width="120px" AllowShowHide="Server" LinkCommand="ViewReclassBatch" ></px:PXGridColumn>
          <px:PXGridColumn DataField="IncludedInReclassHistory" AllowShowHide="False" Visible="false" SyncVisible="false" ></px:PXGridColumn>
          <px:PXGridColumn DataField="UsrLettrageNbr" Width="70" CommitChanges="True" /></Columns>
      </px:PXGridLevel>
    </Levels>
    <AutoSize Container="Window" Enabled="True" MinHeight="400" />
    <ActionBar DefaultAction="DoubleClick" />
  </px:PXGrid>
</asp:Content>

我想念什么?我已经花了几个小时,但我的想法已经用光了。

编辑:

我的最终目标是为过滤器视图上选定行计算贷项和借项之和。如果您有任何变通办法,每次我选择新行时都更新这些值,我会接受。

也许带有一些javascript和回调命令?


我在acumatica合作伙伴中心为此事开了一张支持票。

编辑2:

因此,我创建了自己的自定义选择器:

#region UsrletSel
        [PXBool]
        [PXUIField(DisplayName = "Lettrer")]

        public virtual bool? UsrletSel { get; set; }
        public abstract class usrletSel : IBqlField { }
        #endregion

然后我将基本选择器隐藏在aspx中,为了保持原始逻辑,我将新选择器绑定到基本选择器:

protected void GLTranR_UsrletSel_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            if (e.Row == null) return;
            var row = (GLTranR)e.Row;
            if(row.GetExtension<GLTranExt>().UsrletSel == true)
            {
                row.Selected = true;
            }
            else
            {
                row.Selected = false;
            }
        }

我在aspx中为新字段设置了属性CommitChanges = True,但仍然无法在此屏幕上触发任何事件。

你有什么主意吗?

编辑3:

因此,我总共随机地获得了我的复选框(还有最初选择的复选框)来触发事件。您必须双击该复选框。 (这没有任何意义。)但是我不能真正告诉客户“如果您希望总计计算,请双击双击。”

20秒 http://recordit.co/1fzW3eDIO9

此致

2 个答案:

答案 0 :(得分:1)

最后的答案是在Grid上将属性“ BatchUpdate”设置为“ true”,这阻止了将更改提交到服务器。

将其设置为false即可正常工作:

enter image description here

答案 1 :(得分:0)

据我所知,没有办法做到。

这是同一问题: Checkbox control in a grid is not triggering fieldupdated event

已选择字段似乎绑定了特殊的硬编码逻辑。当您在BLC图表中读取所选值时,它不会提供屏幕上显示的当前值。同样,该字段不会像其他字段一样触发事件。

我发现只有两种方法可以解决此问题:

  1. 使用其他名称的字段,如果该字段名称被选中,则其行为将与其他字段不同。
  2. 尝试仅使用DAC字段属性来实现所有逻辑。这很难实现。

我没有针对#2的完整解决方案,但是如果您只需要全部代码,那么这段代码将是一个不错的开始:

// Selected count
[PXUnboundFormula(typeof(Switch<Case<Where<DAC.selected, Equal<True>>, int1>, int0>), 
                    typeof(SumCalc<FilterDAC.selectedCount>))]
protected void DAC_Selected_CacheAttached(PXCache sender)
{
}

[PXProcessButton]
[PXUIField(DisplayName = "Select All")]
protected virtual void selectAll()
{
    foreach (DAC doc in Dataview.Select())
    {
        if (doc.Selected != true)
        {
            doc.Selected = true;
            Dataview.Cache.SetStatus(doc, PXEntryStatus.Updated);
        }
    }

    FilterDAC copy = PXCache<FilterDAC>.CreateCopy(FilterDAC.Current);
    PXFormulaAttribute.CalcAggregate<DAC.selected>(Dataview.Cache, copy);
    Filter.Update(copy);
}