Acumatica - FieldUpdated - Enable / Disable another control when a checkbox is ticked / un-ticked

…衆ロ難τιáo~ 提交于 2019-12-24 20:09:56

问题


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

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