필터 매개 변수를 기반으로 여러 열 제목 레이블을 변경해야하는 사용자 지정 문의를 개발 중입니다. 사용자는 '시작 기간'을 선택할 수 있으며 선택한 재무 시작 기간 데이터와 이전 기간이 그리드 열에있는 그리드 행에 재무 계정을 표시하려고합니다.
필터 DAC의 RowSelected 이벤트를 사용하여 열 머리글을 설정하고 있습니다. 필터의 시작 기간은 DAC에 의해 기본 설정되며 페이지가 처음로드 될 때 열 머리글이 올바르게 설정됩니다. 그러나 시작 기간 필터 값을 변경할 때 열 머리글은 이후에 업데이트되지 않습니다.
간단한 테스트에서 런타임에 코드를 확인하면 필터 값을 변경할 때 RowSelected 이벤트가 4 번 발생합니다. 처음 두 번은 초기 기본값으로 실행되고 다음 두 번은 사용자가 선택한 값으로 실행되며 문제와 관련이있을 수 있지만 마지막 SetDisplayName 호출이 적용될 것으로 예상됩니다.
사용자가 필터 값을 변경하면 그리드 열 제목을 어떻게 업데이트 할 수 있습니까?
간단한 테스트 사례는 다음과 같습니다 (2019R2에서 개발 중).
using System;
using System.Collections;
using PX.Data;
using PX.Objects.GL;
using PX.Objects.GL.FinPeriods;
namespace FinancialInquirer
{
public class AccountPeriodInquiry : PXGraph<AccountPeriodInquiry>
{
public partial class AccountPeriodInquiryFilter : IBqlTable
{
#region FinPeriodID
[PXUnboundDefault]
[FinPeriodSelector(null,
typeof(AccessInfo.businessDate),
branchSourceType: typeof(GLHistoryEnqFilter.branchID),
organizationSourceType: typeof(GLHistoryEnqFilter.organizationID),
useMasterCalendarSourceType: typeof(GLHistoryEnqFilter.useMasterCalendar),
redefaultOrRevalidateOnOrganizationSourceUpdated: false)]
[PXUIField(DisplayName = "From Period", Visibility = PXUIVisibility.Visible)]
public virtual String FinPeriodID { get; set; }
public abstract class finPeriodID : PX.Data.BQL.BqlString.Field<finPeriodID> { }
#endregion
#region LedgerID
[PXDBInt]
[PXDefault(
typeof(Coalesce<Coalesce<
Search<PX.Objects.GL.DAC.Organization.actualLedgerID,
Where<PX.Objects.GL.DAC.Organization.bAccountID, Equal<Current2<AccountByPeriodFilter.orgBAccountID>>>>,
Search<Branch.ledgerID,
Where<Branch.bAccountID, Equal<Current2<AccountByPeriodFilter.orgBAccountID>>>>>,
Search<Branch.ledgerID,
Where<Branch.branchID, Equal<Current<AccessInfo.branchID>>>>>))]
[PXUIField(DisplayName = "Ledger", Visibility = PXUIVisibility.SelectorVisible)]
[PXSelector(typeof(Search<Ledger.ledgerID, Where<Ledger.balanceType, NotEqual<LedgerBalanceType.budget>>>), SubstituteKey = typeof(Ledger.ledgerCD), DescriptionField = typeof(Ledger.descr))]
public virtual int? LedgerID { get; set; }
public abstract class ledgerID : PX.Data.BQL.BqlInt.Field<ledgerID> { }
#endregion
}
public partial class AccountPeriodResult : IBqlTable
{
#region LedgerID
[PXDBInt(IsKey = true)]
public virtual Int32? LedgerID { get; set; }
public abstract class ledgerID : PX.Data.BQL.BqlInt.Field<ledgerID> { }
#endregion
#region AccountID
[PXDBInt]
[PXDefault()]
public virtual Int32? AccountID { get; set; }
public abstract class accountID : PX.Data.BQL.BqlInt.Field<accountID> { }
#endregion
#region AccountCD
[PXUIField(DisplayName = "Account", Visibility = PXUIVisibility.Visible)]
[PXDBString(10, IsUnicode = true, IsKey = true, InputMask = "")]
[PXDimensionSelectorAttribute(AccountAttribute.DimensionName, typeof(Account.accountCD), typeof(accountCD),
typeof(Account.accountCD), typeof(Account.accountClassID), typeof(Account.type), typeof(Account.description))]
public virtual string AccountCD { get; set; }
public abstract class accountCD : PX.Data.BQL.BqlString.Field<accountCD> { }
#endregion
#region BranchID
[Branch(IsKey = true)]
public virtual Int32? BranchID { get; set; }
public abstract class branchID : PX.Data.BQL.BqlInt.Field<branchID> { }
#endregion
#region Type
[PXDBString(1)]
[PXDefault(AccountType.Income)] //For designer
[AccountType.List]
[PXUIField(DisplayName = "Type")]
public virtual string Type { get; set; }
public abstract class type : PX.Data.BQL.BqlString.Field<type> { }
#endregion
#region Description
[PXDBString(60, IsUnicode = true)]
[PXUIField(DisplayName = "Description")]
public virtual String Description { get; set; }
public abstract class description : PX.Data.BQL.BqlString.Field<description> { }
#endregion
#region AccountClassID
[PXDBString(20, IsUnicode = true)]
[PXUIField(DisplayName = "Account Class")]
[PXSelector(typeof(AccountClass.accountClassID), DescriptionField = typeof(AccountClass.descr))]
public virtual string AccountClassID { get; set; }
public abstract class accountClassID : PX.Data.BQL.BqlString.Field<accountClassID> { }
#endregion
#region Column Totals
[PXDecimal]
[PXUIField(DisplayName = "Period 1")]
public virtual decimal? Per1 { get; set; }
public abstract class per1 : PX.Data.BQL.BqlDecimal.Field<per1> { }
[PXDecimal]
[PXUIField(DisplayName = "Period 2")]
public virtual decimal? Per2 { get; set; }
public abstract class per2 : PX.Data.BQL.BqlDecimal.Field<per2> { }
[PXDecimal]
[PXUIField(DisplayName = "Period 3")]
public virtual decimal? Per3 { get; set; }
public abstract class per3 : PX.Data.BQL.BqlDecimal.Field<per3> { }
[PXDecimal]
[PXUIField(DisplayName = "Period 4")]
public virtual decimal? Per4 { get; set; }
public abstract class per4 : PX.Data.BQL.BqlDecimal.Field<per4> { }
[PXDecimal]
[PXUIField(DisplayName = "Period 5")]
public virtual decimal? Per5 { get; set; }
public abstract class per5 : PX.Data.BQL.BqlDecimal.Field<per5> { }
[PXDecimal]
[PXUIField(DisplayName = "Period 6")]
public virtual decimal? Per6 { get; set; }
public abstract class per6 : PX.Data.BQL.BqlDecimal.Field<per6> { }
#endregion
}
public PXCancel<AccountPeriodInquiryFilter> Cancel;
public PXFilter<AccountPeriodInquiryFilter> Filter;
[PXFilterable]
public PXSelectOrderBy<AccountPeriodResult, OrderBy<Asc<GLHistoryEnquiryResult.accountCD>>> accounts;
public AccountPeriodInquiry()
{
accounts.Cache.AllowInsert = false;
accounts.Cache.AllowDelete = false;
accounts.Cache.AllowUpdate = false;
}
public virtual void AccountPeriodInquiryFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
AccountPeriodInquiryFilter filter = Filter.Current;
// Get the MasterFinPeriod for the Filter value period
MasterFinPeriod filterPeriod = PXSelect<MasterFinPeriod,
Where<MasterFinPeriod.finPeriodID, Equal<Required<MasterFinPeriod.finPeriodID>>,
And<MasterFinPeriod.startDate, NotEqual<MasterFinPeriod.endDate>>>>
.Select(this, filter.FinPeriodID);
// Assign FinPeriodID as column headings
int idx = 0;
var cache = accounts.Cache;
foreach (MasterFinPeriod period in PXSelect<MasterFinPeriod,
Where<MasterFinPeriod.startDate, LessEqual<Required<MasterFinPeriod.startDate>>,
And<MasterFinPeriod.endDate, Greater<Required<MasterFinPeriod.endDate>>,
And<MasterFinPeriod.startDate, NotEqual<MasterFinPeriod.endDate>>>>,
OrderBy<Desc<MasterFinPeriod.startDate>>>
.Select(this, filterPeriod.StartDate, filterPeriod.StartDate.Value.AddMonths(-5)))
{
switch (++idx)
{
case 1: PXUIFieldAttribute.SetDisplayName<AccountPeriodResult.per1>(cache, period.FinPeriodID); break;
case 2: PXUIFieldAttribute.SetDisplayName<AccountPeriodResult.per2>(cache, period.FinPeriodID); break;
case 3: PXUIFieldAttribute.SetDisplayName<AccountPeriodResult.per3>(cache, period.FinPeriodID); break;
case 4: PXUIFieldAttribute.SetDisplayName<AccountPeriodResult.per4>(cache, period.FinPeriodID); break;
case 5: PXUIFieldAttribute.SetDisplayName<AccountPeriodResult.per5>(cache, period.FinPeriodID); break;
case 6: PXUIFieldAttribute.SetDisplayName<AccountPeriodResult.per6>(cache, period.FinPeriodID); break;
}
}
accounts.View.RequestRefresh();
}
public IEnumerable Accounts()
{
// *** Resulting dataset would be generated here ***
yield return new AccountPeriodResult();
}
}
}
그 페이지:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/FormDetail.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="FI401000.aspx.cs" Inherits="Page_FI401000" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/FormDetail.master" %>
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" TypeName="FinancialInquirer.AccountPeriodInquiry" PrimaryView="Filter">
</px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server">
<px:PXFormView ID="form" runat="server" DataSourceID="ds" Style="z-index: 100"
Width="100%" DataMember="Filter" TabIndex="100">
<Template>
<px:PXLayoutRule runat="server" StartRow="True"/>
<px:PXSelector ID="edLedgerID" runat="server" DataField="LedgerID" />
<px:PXSelector ID="edFinPeriodID" runat="server" DataField="FinPeriodID" CommitChanges="True" />
</Template>
</px:PXFormView>
</asp:Content>
<asp:Content ID="cont3" ContentPlaceHolderID="phG" Runat="Server">
<px:PXGrid ID="grid" runat="server" DataSourceID="ds" Style="z-index: 100"
Width="100%" Height="150px" SkinID="Details" TabIndex="300">
<Levels>
<px:PXGridLevel DataKeyNames="LedgerID,AccountCD,BranchID,LastActivityPeriod" DataMember="accounts">
<RowTemplate>
<px:PXSegmentMask ID="edBranchID" runat="server" DataField="BranchID" />
<px:PXDropDown ID="edType" runat="server" DataField="Type" />
<px:PXSelector ID="edAccountClassID" runat="server" DataField="AccountClassID" />
<px:PXSegmentMask ID="edAccountCD" runat="server" DataField="AccountCD" />
<px:PXTextEdit ID="edDescription" runat="server" AlreadyLocalized="False" DataField="Description" />
<px:PXNumberEdit ID="edPer1" runat="server" AlreadyLocalized="False" DataField="Per1" />
<px:PXNumberEdit ID="edPer2" runat="server" AlreadyLocalized="False" DataField="Per2" />
<px:PXNumberEdit ID="edPer3" runat="server" AlreadyLocalized="False" DataField="Per3" />
<px:PXNumberEdit ID="edPer4" runat="server" AlreadyLocalized="False" DataField="Per4" />
<px:PXNumberEdit ID="edPer5" runat="server" AlreadyLocalized="False" DataField="Per5" />
<px:PXNumberEdit ID="edPer6" runat="server" AlreadyLocalized="False" DataField="Per6" />
</RowTemplate>
<Columns>
<px:PXGridColumn DataField="BranchID" Width="140px" />
<px:PXGridColumn DataField="Type" />
<px:PXGridColumn DataField="AccountClassID" Width="140px" />
<px:PXGridColumn DataField="AccountCD" Width="120px" />
<px:PXGridColumn DataField="Description" Width="220px" />
<px:PXGridColumn DataField="Per1" TextAlign="Right" Width="100px" />
<px:PXGridColumn DataField="Per2" TextAlign="Right" Width="100px" />
<px:PXGridColumn DataField="Per3" TextAlign="Right" Width="100px" />
<px:PXGridColumn DataField="Per4" TextAlign="Right" Width="100px" />
<px:PXGridColumn DataField="Per5" TextAlign="Right" Width="100px" />
<px:PXGridColumn DataField="Per6" TextAlign="Right" Width="100px" />
</Columns>
</px:PXGridLevel>
</Levels>
<AutoSize Container="Window" Enabled="True" MinHeight="150" />
</px:PXGrid>
</asp:Content>
aspx 파일의 PXGrid에 RepaintColumns 속성을 추가해야합니다. RepaintColumns는 HTTP 트랜잭션 중에 DisplayName과 같은 필드의 새 속성을 사용하여 열을 다시 만들도록합니다.
<px:PXGrid ID="grid" runat="server" DataSourceID="ds" Style="z-index: 100"
Width="100%" Height="150px" SkinID="Details" TabIndex="300" RepaintColumns="True">
참고로 이것은 그리드에서만 작동합니다. 따라서 사용자 정의 JavaScript를 작성하지 않고는 페이지를 새로 고치지 않고 PXFormView에있는 필드의 UI에서 이름을 변경할 수 없습니다. 누군가 그렇게해야한다면 다른 DisplayName을 가진 두 개의 필드를 만들고 어떤 것이 보이는지 토글해야합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다