$(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: false, vro: false, 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
0

how can i set the OModelData binding with radiobutton

Mar 27, 2017 at 01:30 PM

95

avatar image
Former Member

hello,

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}">
	<buttons>
		<RadioButton text="true"/>
		<RadioButton  text="false"/>
	</buttons>
</RadioButtonGroup>
...........

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

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"); 
	console.log("1");
} else if(setFlag == "0"){ 
	this.getModel("appointments").setProperty("flag", "Yes"); 
	console.log("0");
}			
	this.getModel("appointments").submitChanges();
		}

And I have also tried other possibilities:

this.getModel("appointments").setProperty("/flag", "No"); 
or
this.getView().getModel("appointments").setProperty("/flag", "No"); 
or
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"
					   xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
		<Schema Namespace="timeTrackertimeTracker" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
			<EntityType Name="appointments">
				<Key>
					<PropertyRef Name="Id"/>
				</Key>
				<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"/>
			</EntityType>
		</Schema>
		<Schema Namespace="timeTrackertimeTracker.Model" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
			<EntityContainer Name="timeTrackertimeTrackerEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true"
							 xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
				<EntitySet Name="appointments" EntityType="timeTrackertimeTracker.appointments"/>
			</EntityContainer>
		</Schema>
	</edmx:DataServices>
</edmx:Edmx>

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Jun Wu Mar 27, 2017 at 01:49 PM
0
<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.

Share
10 |10000 characters needed characters left characters exceeded
Dominique Pierre Mar 27, 2017 at 02:27 PM
0

Hi,

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

Cheers,

Pierre

Share
10 |10000 characters needed characters left characters exceeded