Vinny Vinny - 1 year ago 118
Javascript Question

How to select all the input type in SAP UI 5

I have some input tags in my view.xml

<CheckBox checked="true" text="dd" id="chkbx_mxzvw" change = "reacxdData" ></CheckBox>
<CheckBox checked="true" text="eEast" id="chkbx_neqrfd" change = "reacxdData" ></CheckBox>
<CheckBox checked="true" text="wre" id="chkczvbx_w" change = "reacxdData" ></CheckBox>

Is there any way for me to select all the 3 check box and add an attribute setEnabled('false') in my Controller. I have a view instance in the controller

Generally in jQuery we will do it as $('input').attr('disabled',disabled);
Is there any kind of similar thing in SAP UI 5.

Answer Source

I would just bind the enabled property to a local model, and by setting that property to false it will make any bound control readonly.

<CheckBox enabled="{/ui/enabled}" />
<TextInput enabled="{/ui/enabled}" />

Your model then could look like this:

var oModel = new sap.ui.model.json.JSONModel({
    ui : {
        enabled : true

To set all controls which have their enabled property bound to this model property, simply use:

oModel.setProperty("/ui/enabled", false);

On a sidenote, please note sap.ui.commons namespace controls are deprecated as of 1.38

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download