Skip to Content
avatar image
Former Member

how can i set the OModelData binding with radiobutton


i want set a flag property in my OModelData with a radiobutton from my View. if radiobutton in a form set true or false, then i get a 1 or 0 to my Flag of OModelData.

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

	<semantic:SaveAction id="save"  press="onSave"/>

But on the frontend they must be displayed yes or no not 1 or 0.

So I implemented in my onsave function if segment.

onSave: function() {
	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"); 

And I have also tried other possibilities:

this.getModel("appointments").setProperty("/flag", "No"); 
this.getView().getModel("appointments").setProperty("/flag", "No"); 
sap.ui.getCore().getModel("appointments").setProperty("/flag", "true")

All of this can not set the flag property to yes or no.

my metadate:

<edmx:Edmx Version="1.0" xmlns:edmx="">
	<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"
		<Schema Namespace="timeTrackertimeTracker" xmlns="">
			<EntityType Name="appointments">
					<PropertyRef Name="Id"/>
				<Property Name="Id" Type="Edm.String" Nullable="true" />
				<Property Name="projektnummer" Type="Edm.String" Nullable="false" />
				<Property Name="title" Type="Edm.String" Nullable="false"/>

				<Property Name="starttime" Type="Edm.String" Nullable="false" />
			    <Property Name="endtime" Type="Edm.String" Nullable="false" />
			    <Property Name="duration" Type="Edm.Byte" MaxLength="2" Nullable="false" />
			    <Property Name="rest" Type="Edm.Byte" Precision="16" Scale="3" MaxLength="2" Nullable="false" />
			    <Property Name="flag" Type="Edm.String"/>
				<Property Name="description" Type="Edm.String" Nullable="true"/>
		<Schema Namespace="timeTrackertimeTracker.Model" xmlns="">
			<EntityContainer Name="timeTrackertimeTrackerEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true"
				<EntitySet Name="appointments" EntityType="timeTrackertimeTracker.appointments"/>

how can i do it to set the flag propety to "yes" or "no", if the radiobutton is selected.

unbenannt.png (45.5 kB)
unbenannt2.png (62.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 27, 2017 at 01:49 PM
    <RadioButtonGroup columns="3" width="500px" id="flag" selectedIndex="{appointments>flag}"><buttons><RadioButtontext="false"/><RadioButtontext="true"/></buttons></RadioButtonGroup>

    this should be enough for the radio group, you don't have to do anything

    for that table, you can use a formatter to convert the value.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 27, 2017 at 02:27 PM


    You just have to use expression binding or a formatter to display yes for 1 and no for 0 in the table.



    Add comment
    10|10000 characters needed characters exceeded