on 2018 Jan 16 7:34 PM
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("");
}
}
Request clarification before answering.
usually don't go to the ui control to manipulate .
always go through binding.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
so I tried to do the binding but it is still not working.
controller side:
estimatePercentageSelect: function(oEvent) {
var cxt = oEvent.getSource().getBindingContext();
var obj = cxt.getObject();
if (obj.selected) {
obj.percent = "100%";
}
else{
obj.percent = "";
}
}
xml side:
<CheckBox id="checkEstimate" select="estimatePercentageSelect"/>
<Input value="{percent}" width="100%" id="inputPercent"/>
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);
}
}
User | Count |
---|---|
77 | |
30 | |
8 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.