3
votes

I know I can get a binding associated with a control via control.getBinding('example').

Is there anyway to go the opposite way like binding.getControl()?

1
Interesting problem. But how would you get binding without a control ? - Rahul Bhardwaj
Do we have solution for this? - nand

1 Answers

2
votes

Not sure if this helps, but take a look at the control property "fieldGroupIds". It's used for validation purposes so you can call all the controls linked to that specific field group. You could use this to identify all the controls using that specific binding and calling all the controls linked to that field group. See documentation below:

Field Groups

Accessing Controls in a Field Group:

In some scenarios, it is required to find all controls that belong to a specific field group, or to all controls with a fieldGroupId. For this, the control implements the public getControlsByFieldGroupId method that gets a list of child controls in the application code.

var aAllControlsWithFieldGroupId = myVerticalLayout.getControlsByFieldGroupId();              //all where fieldGroupId is not empty 
var aMyGroupControls             = myVerticalLayout.getControlsByFieldGroupId("myGroup");     //exact matches to myGroup

Similar to the above you can use the byFieldGroupId method of sap.ui.Core to all controls with certain field group IDs.

var aAllControlsWithFieldGroupId = sap.ui.getCore().byFieldGroupId();              //all where fieldGroupId is not empty 
var aMyGroupControls             = sap.ui.getCore().byFieldGroupId("MyGroup");     //exact matches to myGroup 
var aNotGrouped                  = sap.ui.getCore().byFieldGroupId([]);            //exact empty array (default value of fieldGroupIds)