How to set value in odata of radiobuttons like inputfield

Mar 23, 2017 at 11:14 AM


avatar image


I create a form now. In a line I need only answer with yes or no. the Code now looks like this

<Label text="Billable" 
<Input value="{appointments>flag}"
	placeholder="set a flag in true or false"/>

and i need radiobuttons with yes or no. I have tried to write radiobutton, but it does not work

<Label text="Billable" />
<VBox binding="{appointments>flag}">
	<RadioButton  text="true"/>
	<RadioButton  text="false"/>

the value property an the RadioButton is not allowed. How can i set the value from radioButton to the {appointments>flag} in ODatamodel like inputfield as above?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Vidhya V Mar 23, 2017 at 12:57 PM
Show 3 Share
10 |10000 characters needed characters left characters exceeded

I would like the selected value from radiobutton set to the {appointments>flag} in the ODatamodel.

In this tutorial I find no solution

A K Mar 24, 2017 at 10:38 AM

Will this helpful? http://plnkr.co/edit/A4ITYuF7MKOMb3ZSA3lI?p=preview

Click the radio button to see the binding concepts :)

Show 2 Share
10 |10000 characters needed characters left characters exceeded

i have changed my View to this:

<Label text="Billable" />
<RadioButtonGroup columns="3" width="500px" id="flag" selectedIndex="{appointments>flag}">
		<RadioButton text="true"/>
		<RadioButton  text="false"/>

the selectedIndex should be either 0 or 1, 0 being true and 1 being false. now my new question. i want set the flag, if 0 then flag value is Yes, if 1 the the flag value is No. how can i do it?

i have set my onSave function:

onSave: function() {

			var setTitle = this.getView().byId("title").getValue();
			var setStarttime = this.getView().byId("startime").getValue();
			var setEndtime = this.getView().byId("endtime").getValue();
			var setFlag = this.getView().byId("flag").getSelectedIndex();

			if(setFlag == "1") {
				this.getModel("appointments").setProperty("flag", "No"); 
			} else if(setFlag == "0"){ 
				this.getModel("appointments").setProperty("flag", "Yes"); 
			if(setTitle == '' || setStarttime == '' || setEndtime == ''){
				sap.m.MessageBox.alert("please set the required fields");

but this this.getModel("appointments").setProperty("flag", "No"); and this.getModel("appointments").setProperty("flag", "Yes"); do not set the property to yes or no. the value is still 0 or 1.

this is my metadata:

<code><edmx:EdmxVersion="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"><edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"
					   xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><SchemaNamespace="timeTrackertimeTracker" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"><EntityTypeName="appointments"><Key><PropertyRefName="Id"/></Key><PropertyName="Id"Type="Edm.String"Nullable="true"/><PropertyName="projektnummer"Type="Edm.String"Nullable="false"/><PropertyName="title"Type="Edm.String"Nullable="false"/><PropertyName="starttime"Type="Edm.String"Nullable="false"/><PropertyName="endtime"Type="Edm.String"Nullable="false"/><PropertyName="duration"Type="Edm.Byte"MaxLength="2"Nullable="false"/><PropertyName="rest"Type="Edm.Byte"Precision="16"Scale="3"MaxLength="2"Nullable="false"/><PropertyName="flag"Type="Edm.String"/><PropertyName="description"Type="Edm.String"Nullable="true"/></EntityType></Schema><SchemaNamespace="timeTrackertimeTracker.Model" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"><EntityContainerName="timeTrackertimeTrackerEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true"

how can i do that if the value is 0 the set flag to Yes, if the value of flag is 1 then set this to No

by the way i've tried with:

this.getModel("appointments").setProperty("/flag", "No"); or
this.getView().getModel("appointments").setProperty("/flag", "No"); or<br>

but they are not set the flag property in my appointments Model

and if i use the code in your plunker

oEvent.getSource().getId() === "idview1--R1" ?
            sap.ui.getCore().getModel("appointments").setProperty("/flag", "true")
          : sap.ui.getCore().getModel("appointments").setProperty("/flag", "false");

they will show:

setProperty is undefined

i dont kown, why undefined?!


Kindly request you to close this thread by marking the correct or helpful answers.

And please open a new thread to discuss new questions :) :) :)

Skip to Content