$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: true, vro: true, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); 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="http://schemas.microsoft.com/ado/2007/06/edmx">
	<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"
		<Schema Namespace="timeTrackertimeTracker" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
			<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="http://schemas.microsoft.com/ado/2008/09/edm">
			<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

  • 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