Changing Acumatica Grid Column Headings at Runtime
Acumatica allows developers to dynamically change the headings of grid columns when the user changes the values of fields that are not in the grid.
For this to work, there are three things that the developer must do. First, the controls that the non-grid fields are bound to must have their CommitChanges property set to True. This is to ensure that changes to their values will cause a postback and that the RowSelected event of the associated cache will be fired.
Next, within the RowSelected event handler of the non-grid cache, the developer must call the PXUIFieldAttribute.SetDisplayName method to specify what the new column heading will be.
Finally, the Grid’s RepaintColumns must be set to True in order to ensure that the grid gets repainted when the postback completes.
Below is an example implementation of the RowSelected event that changes the heading of the Sales Orders screen’s Free Item column. This will change the column heading from “Free Item” to “Ext Free” or “Free” based on the value of the CustomerRefNbr field.
protected void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
if (e.Row == null) return;
SOOrder data = (SOOrder)e.Row;
PXUIFieldAttribute.SetDisplayName<SOLine.isFree>(Base.Transactions.Cache, (data.CustomerRefNbr == “A1”) ? “Ext Free” : “Free”);