Skip to content Skip to sidebar Skip to footer

Activating An Input Field Based On Checkbox Flag In Sapui5

I am trying to activate an input field based on the checkbox flag. The input field is not getting activated. Please help. Below are the snippets from the view and the component.

Solution 1:

You can bind the enbaled property from the input field to the model value of the checkbox. Then if you check the box it should automatically en-/disable the input field.

Something like this:

<CheckBoxid="ch1"text="Test"selected="false"select ="checkDone"value="{someModel>/enabledValue}"enabled="true" /><Inputid="i1"enabled="{someModel>/enabledValue}"></Input>

Solution 2:

checkDone: function (oEvent) {
                 var check = oEvent.getParameter("selected");
                  if (check){
                   this.getView().byId("i1").setEnabled(true);
                 }else{
                   this.getView().byId("i1").setEnabled(false);
                 }
              }

Check with the above code

For place holder inside input

This is not the preferred way but...

<Input  id="i1" enabled="false"class="placeholder"></Input>

onAfterRendering : function(){
   $(".placeholder .sapMInputBaseInner").attr("placeholder", "Your placeholder Text");
}

Post a Comment for "Activating An Input Field Based On Checkbox Flag In Sapui5"