I need to find all Input elements (sap.m.Input) on a website.
I know I can find an element by its ID via sap.ui.getCore().byId() but this does not help me here.
I am looking for something like sap.ui.getCore().getByType("sap.m.Input"). How do I do this?
Edit: I do not have access to the source code of the website, I am injecting a javascript via a chrome extension on websites which use SAPUI5
<mvc:View ...>
<Input fieldGroupIds="myInputs" />
</mvc:View>
// In the Controller
this.getView().getControlsByFieldGroupId("myInputs").filter(c => c.isA("sap.m.Input"));
Leveraging this solution in Get list of all instantiated controls in registry:
const allRegisteredControls = sap.ui.getCore().byFieldGroupId(""); // From https://stackoverflow.com/a/54227512/5846045
const inputControls = allRegisteredControls.filter(c => c.isA("sap.m.Input"));
API reference: sap.ui.base.Object#isA
This returns all registered instances of the given type. Please not that already destroyed elements won't be included.
I found this solution:
I get all elements of the class sap.m.Input from the DOM-Tree with
document.getElementsByClassName("sap.m.Input")`.
I then get the corresponding UI5-Elements by calling sap.ui.getCore().byId() on the ID of each element of that array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With