Skip to Content

checkboxes and input box in table with oData

I created a table in Web IDE that has a checkbox and input box that by default shows "100%" when checkbox is selected. It was working before I added data from a json but now that I made the column list item a template taking in data from the json on some of the columns, the input box does not fill in when selecting checkbox.

this the wanted result

If I use something like message box, it does the correct output when selecting checkbox.

<code>sap.m.MessageBox.alert("100%")
sap.m.MessageBox.alert("0%")

I binded the event to the checkbox under select. This is the code for the checkbox.

<code>    percentCheck: function(oEvent) {
        //inputText is the input Text box  
        var inputText = this.getView().byId("inputPercent");
        var isSelected = oEvent.getParameter("selected");

        if (isSelected) {
            inputText.setValue("100%");
        } else {
            inputText.setValue("");
        }
    }
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 16 at 08:09 PM

    usually don't go to the ui control to manipulate .

    always go through binding.

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks!!! cxt.getModel().setProperty("percent","100%",cxt) worked!!

      I debugged and saw the obj.selected was showing undefined, so I used the event parameter to show if checkbox was selected or not

      estimatePercentageSelect: function(oEvent) {
      var isSelected = oEvent.getParameter("selected");
      var cxt = oEvent.getSource().getBindingContext();
            
      if (isSelected) {
            cxt.getModel().setProperty("percent","100%",cxt);
            }
            else{
            	cxt.getModel().setProperty("percent",null,cxt);
            }
      }
  • Jan 17 at 06:53 AM

    Hi

    I think its because you have the binding now , you are not changing the bind value, you are changing at the level of the ui control ..

    Jun Wu is correct try using the bindings , don't set value using setValue function ..

    thanks

    Viplove

    Add comment
    10|10000 characters needed characters exceeded