问题
I have two custom fields, one is a tickbox, and the other is a text box, I wanted to change enabled/disable the text field on the screen when the tickbox value is changed, I added an event handler on the FieldUpdated event for the boolean checkbox control, and got the following code:
protected void CROpportunity_MyCheckbox_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (CROpportunity)e.Row;
}
Can I, and how to access other controls from this context?
I guess I need to enable CommitChanges on the checkbox which I did.
Thanks
回答1:
You should use RowSelected
event handler for enabling/disabling controls.
Here is an example of how you can do that:
protected virtual void CROpportunity_RowSelected(PXCache sender, PXRowSelectedEventArgs e,PXRowSelected baseMethod)
{
baseMethod?.Invoke(sender, e);
if(e.Row is CROpportunity row)
{
CROpportunityExt rowExt = PXCache<CROpportunity>.GetExtension<CROpportunityExt>(row);
PXUIFieldAttribute.SetEnabled<CROpportunityExt.myTextField>(cache,row,rowExt.MyCheckbox==true)
}
}
来源:https://stackoverflow.com/questions/56734510/acumatica-fieldupdated-enable-disable-another-control-when-a-checkbox-is-t