Skip to main content
Answer

How to disable a custom field in a grid

  • August 29, 2022
  • 2 replies
  • 1155 views

Joe Schmucker
Captain II
Forum|alt.badge.img+3

I have a user defined field in the APTran table (Bills and Adjustments screen).  There are actually two fields, UsrAllocationID (Unbound field for use only on the grid) and UsrAllocationID which is stored in the APTran table to save the history of the allocation ID used on the line.  

	public class APTranExt : PXCacheExtension<PX.Objects.AP.APTran>
{
#region UsrAllocationID
[PXInt]
[PXUIField(DisplayName = "Allocation Code ID")]
[PXSelector(typeof(Search<ICAllocationCode.allocationID, Where<ICAllocationCode.active.IsEqual<True>>>),
typeof(ICAllocationCode.allocationCD),
typeof(ICAllocationCode.description),
SubstituteKey = typeof(ICAllocationCode.allocationCD),
DescriptionField = typeof(ICAllocationCode.description))]
public virtual int? UsrAllocationID { get; set; }
public abstract class usrAllocationID : PX.Data.BQL.BqlInt.Field<usrAllocationID> { }
#endregion


#region UsrAllocationIDUsed
[PXDBInt]
[PXUIField(DisplayName = "Allocation ID Used", Enabled = false)]
[PXDefault(typeof(Select<ICAllocationCode>), PersistingCheck = PXPersistingCheck.Nothing)]
[PXSelector(typeof(Search<ICAllocationCode.allocationID>),
typeof(ICAllocationCode.allocationCD),
typeof(ICAllocationCode.description),
SubstituteKey = typeof(ICAllocationCode.allocationCD),
DescriptionField = typeof(ICAllocationCode.description))]
public virtual int? UsrAllocationIDUsed { get; set; }
public abstract class usrAllocationIDUsed : PX.Data.BQL.BqlInt.Field<usrAllocationIDUsed> { }
#endregion
}

I want the Allocation ID Used column to be read only.  

I set the Enabled = false in the DAC.

In the row template, I have the settings that I think should make this read only.

<px:PXSelector runat="server" ID="CstPXSelector1" DataField="UsrAllocationIDUsed" AllowEdit="True" Enabled="False" AllowAddNew="False" />

I’m not sure what else to try.

Thanks,

Joe

Best answer by Dioris Aguilar

@joe21 The Enabled = false in the DAC should be enough. Does your code have some logic like this: 

PXUIFieldAttribute.SetEnabled<APTranExt.usrAllocationIDUsed>(...)?

2 replies

Dioris Aguilar
Jr Varsity I
Forum|alt.badge.img+2
  • Jr Varsity I
  • Answer
  • August 29, 2022

@joe21 The Enabled = false in the DAC should be enough. Does your code have some logic like this: 

PXUIFieldAttribute.SetEnabled<APTranExt.usrAllocationIDUsed>(...)?


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • August 29, 2022

@Dioris Aguilar  It does not have anything like that. 

I just put this in the row selected.  Works like a charm.  Thanks for the tip!!

        protected virtual void _(Events.RowSelected<APTran> e)
        {
            APTran line = e.Row;
            if (line is null) return;
            APTranExt itemExt = line.GetExtension<APTranExt>();
            PXUIFieldAttribute.SetEnabled<APTranExt.usrAllocationIDUsed>(e.Cache, line, false);
        }