Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Hiding Object Attribute Element based on certain value from Odata

Hello,

We have a requirement for adding an extra field to the "Approve Leave Request" but that will only appear with a certain type of leave.

This is the code in the extended view. The field is called "S3_TRAQS". I tried adding the logic in the Onafterrendering function, but  I'm not sure how to get the data from the odata service and access the visibility of the object attribute.

Thanks

Asmaa

<!--

    Copyright (C) 2009-2014 SAP SE or an SAP affiliate company. All rights reserved

-->

<core:View controllerName="hcm.approve.leaverequest.view.S3" xmlns:core="sap.ui.core" xmlns:form="sap.ui.layout.form"

  xmlns:layout="sap.ui.layout" xmlns:me="sap.me" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m">

  <Page id="detailPage" path="{a>/Details}">

  <ObjectHeader id="S3_DETAILHEADHER"

  number="{parts:[{path:'AbsenceDays'},{path:'AbsenceHours'},{path:'AllDayFlag'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterAbsenceDuration'}"

  numberUnit="{parts:[{path:'AbsenceDays'},{path:'AbsenceHours'},{path:'AllDayFlag'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterAbsenceDurationUnit'}"

  title="{RequesterName}" titleActive="true" titlePress="_handleNamePress">

  <statuses>

  <ObjectStatus id="S3_CHANGEDATE"

  text="{parts:[{path:'ChangeDate'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterTimestampToDate'}"></ObjectStatus>

  <ObjectStatus id="S3_CANCELSTATUS" state="Warning"

  text="{parts:[{path:'LeaveRequestType'},{path:'RequesterName'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterHeaderCancelStatus'}"></ObjectStatus>

  </statuses>

  <attributes>

  <ObjectAttribute id="S3_REQ_PERNR"

  text="{parts:[{path:'RequesterNumber'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterEmployeeID'}"></ObjectAttribute>

  <ObjectAttribute id="S3_LEAVEDESC" text="{LeaveTypeDesc}"></ObjectAttribute>

  <ObjectAttribute id="S3_TIMEFRAME"

  text="{parts:[{path:'StartDate'},{path:'BeginTime'},{path:'EndDate'},{path:'EndTime'},{path:'AllDayFlag'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterAbsenceDays3'}"></ObjectAttribute>

  </attributes>

  <!-- extension point for additional fields in header -->

  <core:ExtensionPoint name="extS3Header">

  <ObjectAttribute id="S3_TRAQS" text="E-Learning"></ObjectAttribute>

  </core:ExtensionPoint>

  </ObjectHeader>

  <IconTabBar id="LRAtc" select="_handleTabSelect">

  <items>

  <IconTabFilter icon="sap-icon://hint" iconColor="Default" key="contentInfo">

  <content>

  <form:Form id="myForm">

  <form:layout>

  <form:ResponsiveLayout id="informationLayout"/>

  </form:layout>

  <form:formContainers>

  <form:FormContainer id="formContainer">

  <form:layoutData>

  <layout:ResponsiveFlowLayoutData linebreak="true" margin="false"></layout:ResponsiveFlowLayoutData>

  </form:layoutData>

  <form:formElements>

  <form:FormElement id="S3_TIME_QUOTA_FELEM"

  visible="{parts:[{path:'CurrentBalTimeUnitCode'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterCurrentBalanceVisible'}">

  <form:layoutData>

  <layout:ResponsiveFlowLayoutData linebreak="true" margin="false"></layout:ResponsiveFlowLayoutData>

  </form:layoutData>

  <form:label>

  <Label id="CurrentBalanceLabel" text="{i18n>view.AddInfo.CurrentBalance}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData min-width="192" weight="3"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Label>

  </form:label>

  <form:fields>

  <Text id="CurrentBalance"

  text="{parts:[{path:'CurrentBalance'},{path:'CurrentBalTimeUnitCode'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterCurrentBalance'}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData weight="5"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Text>

  </form:fields>

  </form:FormElement>

  <form:FormElement>

  <form:layoutData>

  <layout:ResponsiveFlowLayoutData linebreak="true" margin="false"></layout:ResponsiveFlowLayoutData>

  </form:layoutData>

  <form:label>

  <Label id="RequestedLabel" text="{i18n>view.AddInfo.Requested}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData min-width="192" weight="3"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Label>

  </form:label>

  <form:fields>

  <Text id="Requested"

  text="{parts:[{path:'AbsenceDays'},{path:'AbsenceHours'},{path:'AllDayFlag'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterAbsenceDurationAndUnit'}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData weight="5"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Text>

  </form:fields>

  </form:FormElement>

  <form:FormElement id="S3_Duration"

  visible="{parts:[{path:'AllDayFlag'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterTimeDurationVisible'}">

  <form:layoutData>

  <layout:ResponsiveFlowLayoutData linebreak="true" margin="false"></layout:ResponsiveFlowLayoutData>

  </form:layoutData>

  <form:label>

  <Label id="S3_DurationLabel" text="{i18n>view.Detail.FromTo}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData min-width="192" weight="3"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Label>

  </form:label>

  <form:fields>

  <Text id="RequestedDurationTime"

  text="{parts:[{path:'BeginTime'},{path:'EndTime'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterDurationTime'}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData weight="5"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Text>

  </form:fields>

  </form:FormElement>

  <form:FormElement>

  <form:layoutData>

  <layout:ResponsiveFlowLayoutData linebreak="true" margin="false"></layout:ResponsiveFlowLayoutData>

  </form:layoutData>

  <form:label>

  <Label id="LeaveType" text="{i18n>view.AddInfo.LeaveType}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData min-width="192" weight="3"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Label>

  </form:label>

  <form:fields>

  <Text id="formLeaveTypeDesc" text="{LeaveTypeDesc}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData weight="5"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Text>

  </form:fields>

  </form:FormElement>

  <form:FormElement id="Overlaps" visible="false">

  <form:layoutData>

  <layout:ResponsiveFlowLayoutData linebreak="true" margin="false"></layout:ResponsiveFlowLayoutData>

  </form:layoutData>

  <form:label>

  <Label id="OverlapListLabel">

  <layoutData>

  <layout:ResponsiveFlowLayoutData min-width="192" weight="3"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Label>

  </form:label>

  <form:fields>

  <Text id="OverlapList" text="{parts:[{path:'OverlapList'}], formatter:'hcm.approve.leaverequest.util.Conversions._parseOverlapList'}">

  <layoutData>

  <layout:ResponsiveFlowLayoutData align-items="End" weight="5"></layout:ResponsiveFlowLayoutData>

  </layoutData>

  </Text>

  </form:fields>

  </form:FormElement>

  </form:formElements>

  </form:FormContainer>

  </form:formContainers>

  </form:Form>

  </content>

  </IconTabFilter>

  <IconTabFilter count="{NotesCounter}" icon="sap-icon://notes" iconColor="Default" key="contentNotes"

  visible="{parts:[{path:'NotesCounter'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterNotesVisible'}">

  <List headerDesign="Plain" id="NotesList" inset="false" items="{notes>/NotesCollection}" showSeparators="None">

  <FeedListItem id="feed" sender="{notes>Author}" senderPress="_handleSenderPress" text="{notes>Text}" timestamp="{notes>Timestamp}"></FeedListItem>

  </List>

  </IconTabFilter>

  <IconTabFilter count="{AttachmentsCounter}" icon="sap-icon://attachment" id="S3_ATTACH_ICNTAB"

  visible="{parts:[{path:'AttachmentsCounter'}], formatter:'hcm.approve.leaverequest.util.Conversions.formatterNotesVisible'}">

  <content>

  <layout:VerticalLayout width="100%">

  <UploadCollection id="S3_FILE_LIST" items="{files>/AttachmentsCollection}" uploadEnabled="false">

  <UploadCollectionItem contributor="{files>Contributor}" documentId="{files>DocumentId}" enableDelete="false" enableEdit="false"

  fileName="{files>FileName}" fileSize="{files>FileSize}" mimeType="{files>MimeType}" uploadedDate="{files>UploadedDate}"

  url="{files>FileUrl}"></UploadCollectionItem>

  </UploadCollection>

  </layout:VerticalLayout>

  </content>

  </IconTabFilter>

  <IconTabFilter count="{Overlaps}" icon="sap-icon://calendar" id="S3_OverlapCalendar" key="calendar" visible="false">

  <content>

  <me:OverlapCalendar changeDate="_onChangeDate" endOfData="_onEndOfData" id="OverlapCalendar2" startDate="2015-04-16T00:00:00"

  swipeToNavigate="false" weeksPerRow="2"></me:OverlapCalendar>

  <me:CalendarLegend id="CalenderLegend" legendWidth="18em"></me:CalendarLegend>

  <Text class="sapUiSmallMarginBeginEnd sapUiSmallMarginTop" id="infoText" textAlign="Center" width="80em"></Text>

  </content>

  </IconTabFilter>

  <!-- extension point for additional IconTabFilter -->

  <core:ExtensionPoint name="extS3Tab"/>

  </items>

  </IconTabBar>

  <footer>

  <Bar id="detailFooter"></Bar>

  </footer>

  </Page>

</core:View>

Tags:
replied

Hi Asmaa,

I don't see the filed with id S3_TTRAQS in the view code. Am i missing something or you forgot to add?

After adding that, try running your code. It should work.

PS: You may have a problem in maintaining the initial state of the application. For this you should also control and initialize the visible property of new control in the onInit() function.

BR.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question