A little trick to view all public methods of UI5 controls

 

A small tip: For example, I want to set the width of each column in the UI5 ​​table control to be adaptive according to the displayed content. I need to know which method of the control should be called to achieve this.

One way is, of course, to check the SAP help documentation and know that the public method setAutoSizable of the control needs to be called.

Another way is to study in the debugger, because according to experience, the name of this public method generally starts with set by convention, as shown below:

As a rule of thumb, navigate from all entries in the set autocomplete list in the debugger to the method setAutoResizable should be called. The next question is what parameters should be passed in this method.

Execute the method getMetadata directly in the debugger, and expand the returned results: 

In the autoResizable of _mProperties, I know that this set method should pass a boolean type parameter into it: 

reflection

This idea is to obtain the metadata of the control at runtime, which is actually similar to Java's reflection and ABAP's RTTI.

To get more original technical articles from Jerry, please follow the public account "Wang Zixi" or scan the QR code below:

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326101787&siteId=291194637