Changing column name dynamically

随声附和 提交于 2019-12-04 02:33:25

问题


I have a Header / Detail custom screen where I'm manipulating which grid columns display based on a dropdown selection in the header. This works fine, but now I'd like to change a few column names as well. Using the documented syntax, I cannot get this to work. I can't see what I'm doing wrong - nothing seems to make any difference. I've attached to process and put a break point at this event, and it's hitting the line - but the system seems to just ignore it:

    protected virtual void ACMappingHeader_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        var mh = (ACMappingHeader)e.Row;
        if (mh == null) return;

        if (mh.MappingType == "Option1")
        {
            PXUIFieldAttribute.SetDisplayName<ACMappingDetail.target1CD>(this.MappingDetail.Cache, "Target");

Thanks...


回答1:


Your display name routine looks correct however to make sure the column names actually update you need to do the following:

  • In the page source, you need to set the "RepaintColumns=true" value on the grid. This can be done via customization manager or directly from your ASPX source. - This tells the grid to refresh the columns after a callback allowing the headers to actually redisplay.



回答2:


You can refer below example to dynamically change Grid Column Header.

Below example works with Screen PM401000 – Project Transactions Inquiry

public class TransactionInquiryExt : PXGraphExtension<TransactionInquiry>
{
    public void TranFilter_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseInvoke)
    {
        if (baseInvoke != null)
            baseInvoke(cache, e);

        PX.Objects.PM.TransactionInquiry.TranFilter row = e.Row as PX.Objects.PM.TransactionInquiry.TranFilter;

        if (row == null) return;

        PXUIFieldAttribute.SetDisplayName<PMTran.description>(Base.Transactions.Cache,
            row.ProjectID.HasValue ? "Description for Project Tran" : "Description");
    }
}

Make sure to set RepaitColumns property to True of PXGrid Control.



来源:https://stackoverflow.com/questions/37838922/changing-column-name-dynamically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!