cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the UI5 control from a model property

bblanckaert
Explorer
0 Kudos

I have several UI5 Table controls bound to the same model property. The tables are not necessarily rendered already (using lazy loading).

In a validation step, I'm doing some checks on the model's values. If I found an error, I want to invalidate all table cells that contain the erroneous value. Is there a way to find all current UI5 controls that are bound to a certain bindingcontext (Model + path)?

Accepted Solutions (0)

Answers (2)

Answers (2)

maheshpalavalli
Active Contributor
0 Kudos

The best way is use the message manager. You may not be able to find a lot blogs on that, but going with that approach is a lot better.

https://blogs.sap.com/2017/03/26/show-bapi-warning-messages-in-ui5-without-throwing-exceptions/

There is reusable js module also written for that:

https://blogs.sap.com/2015/11/01/generic-sapui5-form-validator/

bblanckaert
Explorer
0 Kudos

Both approaches require the UI5 control to be instantiated already.

Perhaps some more constraints:

  • My app is deployed on a SAP PO system (Java stack), no OData services from an ECC or S/4 system are used.
  • I'm using a sap.uxap.ObjectPageLayout with lazy loading. It means that the different sections are only loaded when the user scrolls/navigates to them
  • In step 1, the user can enter some data and save this data. No checks are done in this case; in step 2 the data are submitted for validation by an approver. It's upon this submit for validation that some data are checked. Since the section where the data is visualized is not necessarily loaded yet, the erroneous data might not be linked to a control yet. Hence my need to check if a control is linked to certain data in my model.
  • For data in simple controls, it's easy to keep a mapping between data and control, but my main problem is for data in tables, where you the sId for each control is generated automatically.
junwu
Active Contributor
0 Kudos

usually it is a bad idea to access the ui control.

in most case, you can just manipulate the data to achieve what you want.

bblanckaert
Explorer
0 Kudos

Hi Jun, I want to invalidate the controls (mark them with a red border). Would you know how to achieve that without accessing the control itself?