Solved

How to disable a custom field in a grid

  • 29 August 2022
  • 2 replies
  • 756 views

Userlevel 6
Badge +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

icon

Best answer by Dioris Aguilar 29 August 2022, 21:33

View original

2 replies

Userlevel 5
Badge +2

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

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

Userlevel 6
Badge +3

@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);
        }
 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved