title: Multiple Changes to Grid Column DisplayName not working
body: <p>I'm developing a custom inquiry that needs to change multiple column heading labels based on the filter parameters.  The user can select a 'Starting Period' and I want to display financial accounts in grid rows with the selected financial starting period data and preceding periods in the grid columns.</p>
  
  <p>I'm using the RowSelected event of the Filter DAC to set the column headings. The Starting Period of the filter is defaulted by the DAC and the column headings are set correctly when the page is initially loaded. However, upon changing the Starting Period filter value the column headings are not subsequently updated.</p>
  
  <p>Checking the code at run-time in a simplified test I see the RowSelected event fires four times when changing the filter value. The first two times it runs with the initial default value and the subsequent two with the user selected value which I suspect may be related to the issue but expect the last SetDisplayName call should be getting applied.</p>
  
  <p>How can I update the grid column headings in response to the user changing the filter value?</p>
  
  <p>A simplified test case is here (developing in 2019R2):</p>
  
  <pre><code>using System;
  using System.Collections;
  using PX.Data;
  using PX.Objects.GL;
  using PX.Objects.GL.FinPeriods;
  
  namespace FinancialInquirer
  {
      public class AccountPeriodInquiry : PXGraph&lt;AccountPeriodInquiry&gt;
      {
          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&lt;finPeriodID&gt; { }
              #endregion
  
              #region LedgerID
              [PXDBInt]
              [PXDefault(
                  typeof(Coalesce&lt;Coalesce&lt;
                      Search&lt;PX.Objects.GL.DAC.Organization.actualLedgerID,
                          Where&lt;PX.Objects.GL.DAC.Organization.bAccountID, Equal&lt;Current2&lt;AccountByPeriodFilter.orgBAccountID&gt;&gt;&gt;&gt;,
                      Search&lt;Branch.ledgerID,
                          Where&lt;Branch.bAccountID, Equal&lt;Current2&lt;AccountByPeriodFilter.orgBAccountID&gt;&gt;&gt;&gt;&gt;,
                      Search&lt;Branch.ledgerID,
                          Where&lt;Branch.branchID, Equal&lt;Current&lt;AccessInfo.branchID&gt;&gt;&gt;&gt;&gt;))]
              [PXUIField(DisplayName = "Ledger", Visibility = PXUIVisibility.SelectorVisible)]
              [PXSelector(typeof(Search&lt;Ledger.ledgerID, Where&lt;Ledger.balanceType, NotEqual&lt;LedgerBalanceType.budget&gt;&gt;&gt;), SubstituteKey = typeof(Ledger.ledgerCD), DescriptionField = typeof(Ledger.descr))]
              public virtual int? LedgerID { get; set; }
              public abstract class ledgerID : PX.Data.BQL.BqlInt.Field&lt;ledgerID&gt; { }
              #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&lt;ledgerID&gt; { }
              #endregion
              #region AccountID
              [PXDBInt]
              [PXDefault()]
              public virtual Int32? AccountID { get; set; }
              public abstract class accountID : PX.Data.BQL.BqlInt.Field&lt;accountID&gt; { }
              #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&lt;accountCD&gt; { }
              #endregion
              #region BranchID
              [Branch(IsKey = true)]
              public virtual Int32? BranchID { get; set; }
              public abstract class branchID : PX.Data.BQL.BqlInt.Field&lt;branchID&gt; { }
              #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&lt;type&gt; { }
              #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&lt;description&gt; { }
              #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&lt;accountClassID&gt; { }
              #endregion
  
              #region Column Totals
              [PXDecimal]
              [PXUIField(DisplayName = "Period 1")]
              public virtual decimal? Per1 { get; set; }
              public abstract class per1 : PX.Data.BQL.BqlDecimal.Field&lt;per1&gt; { }
  
              [PXDecimal]
              [PXUIField(DisplayName = "Period 2")]
              public virtual decimal? Per2 { get; set; }
              public abstract class per2 : PX.Data.BQL.BqlDecimal.Field&lt;per2&gt; { }
  
              [PXDecimal]
              [PXUIField(DisplayName = "Period 3")]
              public virtual decimal? Per3 { get; set; }
              public abstract class per3 : PX.Data.BQL.BqlDecimal.Field&lt;per3&gt; { }
  
              [PXDecimal]
              [PXUIField(DisplayName = "Period 4")]
              public virtual decimal? Per4 { get; set; }
              public abstract class per4 : PX.Data.BQL.BqlDecimal.Field&lt;per4&gt; { }
  
              [PXDecimal]
              [PXUIField(DisplayName = "Period 5")]
              public virtual decimal? Per5 { get; set; }
              public abstract class per5 : PX.Data.BQL.BqlDecimal.Field&lt;per5&gt; { }
  
              [PXDecimal]
              [PXUIField(DisplayName = "Period 6")]
              public virtual decimal? Per6 { get; set; }
              public abstract class per6 : PX.Data.BQL.BqlDecimal.Field&lt;per6&gt; { }
              #endregion
          }
  
          public PXCancel&lt;AccountPeriodInquiryFilter&gt; Cancel;
          public PXFilter&lt;AccountPeriodInquiryFilter&gt; Filter;
          [PXFilterable]
          public PXSelectOrderBy&lt;AccountPeriodResult, OrderBy&lt;Asc&lt;GLHistoryEnquiryResult.accountCD&gt;&gt;&gt; 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&lt;MasterFinPeriod,
                  Where&lt;MasterFinPeriod.finPeriodID, Equal&lt;Required&lt;MasterFinPeriod.finPeriodID&gt;&gt;,
                      And&lt;MasterFinPeriod.startDate, NotEqual&lt;MasterFinPeriod.endDate&gt;&gt;&gt;&gt;
                  .Select(this, filter.FinPeriodID);
  
              // Assign FinPeriodID as column headings
              int idx = 0;
              var cache = accounts.Cache;
              foreach (MasterFinPeriod period in PXSelect&lt;MasterFinPeriod,
                  Where&lt;MasterFinPeriod.startDate, LessEqual&lt;Required&lt;MasterFinPeriod.startDate&gt;&gt;,
                      And&lt;MasterFinPeriod.endDate, Greater&lt;Required&lt;MasterFinPeriod.endDate&gt;&gt;,
                      And&lt;MasterFinPeriod.startDate, NotEqual&lt;MasterFinPeriod.endDate&gt;&gt;&gt;&gt;,
                  OrderBy&lt;Desc&lt;MasterFinPeriod.startDate&gt;&gt;&gt;
                  .Select(this, filterPeriod.StartDate, filterPeriod.StartDate.Value.AddMonths(-5)))
              {
                  switch (++idx)
                  {
                      case 1: PXUIFieldAttribute.SetDisplayName&lt;AccountPeriodResult.per1&gt;(cache, period.FinPeriodID); break;
                      case 2: PXUIFieldAttribute.SetDisplayName&lt;AccountPeriodResult.per2&gt;(cache, period.FinPeriodID); break;
                      case 3: PXUIFieldAttribute.SetDisplayName&lt;AccountPeriodResult.per3&gt;(cache, period.FinPeriodID); break;
                      case 4: PXUIFieldAttribute.SetDisplayName&lt;AccountPeriodResult.per4&gt;(cache, period.FinPeriodID); break;
                      case 5: PXUIFieldAttribute.SetDisplayName&lt;AccountPeriodResult.per5&gt;(cache, period.FinPeriodID); break;
                      case 6: PXUIFieldAttribute.SetDisplayName&lt;AccountPeriodResult.per6&gt;(cache, period.FinPeriodID); break;
                  }
              }
  
              accounts.View.RequestRefresh();
          }
  
          public IEnumerable Accounts()
          {
              // *** Resulting dataset would be generated here ***
              yield return new AccountPeriodResult();
          }
      }
  }
  </code></pre>
  
  <p>The page:</p>
  
  <pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/MasterPages/FormDetail.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="FI401000.aspx.cs" Inherits="Page_FI401000" Title="Untitled Page" %&gt;
  &lt;%@ MasterType VirtualPath="~/MasterPages/FormDetail.master" %&gt;
  
  &lt;asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server"&gt;
      &lt;px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" TypeName="FinancialInquirer.AccountPeriodInquiry" PrimaryView="Filter"&gt;
      &lt;/px:PXDataSource&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server"&gt;
      &lt;px:PXFormView ID="form" runat="server" DataSourceID="ds" Style="z-index: 100" 
          Width="100%" DataMember="Filter" TabIndex="100"&gt;
          &lt;Template&gt;
              &lt;px:PXLayoutRule runat="server" StartRow="True"/&gt;
              &lt;px:PXSelector ID="edLedgerID" runat="server" DataField="LedgerID" /&gt;
              &lt;px:PXSelector ID="edFinPeriodID" runat="server" DataField="FinPeriodID" CommitChanges="True" /&gt;
          &lt;/Template&gt;
      &lt;/px:PXFormView&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="cont3" ContentPlaceHolderID="phG" Runat="Server"&gt;
      &lt;px:PXGrid ID="grid" runat="server" DataSourceID="ds" Style="z-index: 100" 
          Width="100%" Height="150px" SkinID="Details" TabIndex="300"&gt;
          &lt;Levels&gt;
              &lt;px:PXGridLevel DataKeyNames="LedgerID,AccountCD,BranchID,LastActivityPeriod" DataMember="accounts"&gt;
                  &lt;RowTemplate&gt;
                      &lt;px:PXSegmentMask ID="edBranchID" runat="server" DataField="BranchID" /&gt;
                      &lt;px:PXDropDown ID="edType" runat="server" DataField="Type" /&gt;
                      &lt;px:PXSelector ID="edAccountClassID" runat="server" DataField="AccountClassID" /&gt;
                      &lt;px:PXSegmentMask ID="edAccountCD" runat="server" DataField="AccountCD" /&gt;
                      &lt;px:PXTextEdit ID="edDescription" runat="server" AlreadyLocalized="False" DataField="Description" /&gt;
                      &lt;px:PXNumberEdit ID="edPer1" runat="server" AlreadyLocalized="False" DataField="Per1" /&gt;
                      &lt;px:PXNumberEdit ID="edPer2" runat="server" AlreadyLocalized="False" DataField="Per2" /&gt;
                      &lt;px:PXNumberEdit ID="edPer3" runat="server" AlreadyLocalized="False" DataField="Per3" /&gt;
                      &lt;px:PXNumberEdit ID="edPer4" runat="server" AlreadyLocalized="False" DataField="Per4" /&gt;
                      &lt;px:PXNumberEdit ID="edPer5" runat="server" AlreadyLocalized="False" DataField="Per5" /&gt;
                      &lt;px:PXNumberEdit ID="edPer6" runat="server" AlreadyLocalized="False" DataField="Per6" /&gt;
                  &lt;/RowTemplate&gt;
                  &lt;Columns&gt;
                      &lt;px:PXGridColumn DataField="BranchID" Width="140px" /&gt;
                      &lt;px:PXGridColumn DataField="Type" /&gt;
                      &lt;px:PXGridColumn DataField="AccountClassID" Width="140px" /&gt;
                      &lt;px:PXGridColumn DataField="AccountCD" Width="120px" /&gt;
                      &lt;px:PXGridColumn DataField="Description" Width="220px" /&gt;
                      &lt;px:PXGridColumn DataField="Per1" TextAlign="Right" Width="100px" /&gt;
                      &lt;px:PXGridColumn DataField="Per2" TextAlign="Right" Width="100px" /&gt;
                      &lt;px:PXGridColumn DataField="Per3" TextAlign="Right" Width="100px" /&gt;
                      &lt;px:PXGridColumn DataField="Per4" TextAlign="Right" Width="100px" /&gt;
                      &lt;px:PXGridColumn DataField="Per5" TextAlign="Right" Width="100px" /&gt;
                      &lt;px:PXGridColumn DataField="Per6" TextAlign="Right" Width="100px" /&gt;
                  &lt;/Columns&gt;
              &lt;/px:PXGridLevel&gt;
          &lt;/Levels&gt;
          &lt;AutoSize Container="Window" Enabled="True" MinHeight="150" /&gt;
      &lt;/px:PXGrid&gt;
  &lt;/asp:Content&gt;
  </code></pre>