Hi Gurus,
I am trying to access to an element in an XML fragment, which is implemented for an extension point, and set it invisible, but I failed to make it.
I dug some blogs or docs, e.g. Retrieving Control Instances by their ID - UI Development Toolkit for HTML5 (SAPUI5) - SAP Library
And someone says using the sap.ui.getCore().byId("...."), something like this. I've tried them all and nothing different came up.
Here is where the extension point is.
I've extended it successfully because the all content inside it can be displayed, and here is the content.
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns:crm="sap.cus.crm.lib.reuse.controls" xmlns="sap.m" xmlns:me="sap.me" xmlns:form="sap.ui.layout.form" xmlns:element="sap.ui.layout.form.FormElement" xmlns:dlg="sap.m.dialog" xmlns:layout="sap.ui.layout" xmlns:mvc="sap.ui.core.mvc" xmlns:caui="sap.ca.ui"> <!-- This extension point can be used to add fields to Page --> <Panel xmlns="sap.m" id="Sample_Request_Info_Panel" expandable="true" expanded="false"> <headerToolbar> <Toolbar id="Sample_Request_Info_Toolbar"> <Text text="{i18n>view.Appointment.sampleRequest}" class="sapMH4FontSize"/> </Toolbar> </headerToolbar> <content> <form:SimpleForm id="Sample_Request_Info_Form" maxContainerCols="2" editable="false"> <form:content> <layout:VerticalLayout id="Sample_Request_Info_Layout"> <layout:HorizontalLayout id="technician"> <Label id="technicianLabel" text="{i18n>view.Appointment.technician}:"/> <Text id="technicianText" text="{TechnicianName}"/> </layout:HorizontalLayout> <layout:HorizontalLayout id="productLine"> <Label id="productLineLabel" text="{i18n>view.Appointment.productLine}:"/> <Text id="productLineText" text="{ProductLine}"/> </layout:HorizontalLayout> <layout:HorizontalLayout id="trademark"> <Label id="trademarkLabel" text="{i18n>view.Appointment.trademark}:"/> <Text id="trademarkText" text="{Trademark}"/> </layout:HorizontalLayout> <layout:HorizontalLayout id="requestWeight"> <Label id="requestWeightLabel" text="{i18n>view.Appointment.requestWeight}: "/> <Text id="requestWeightText" text="{Quantity} {Unit}"/> </layout:HorizontalLayout> </layout:VerticalLayout> </form:content> </form:SimpleForm> </content> </Panel></core:FragmentDefinition>Then I code the lines like this trying to access to the fragment definition/implemented extension point.
onBeforeRendering: function() {
var b = this.getView().getBindingContext(); if (b) { this.transType = this.oModel.getProperty(b.sPath).TransactionType; // Hide the unnecessary information. this.sampleInfo = this.byId(sap.ui.core.Fragment.createId("extBeforeDocHistory", "Sample_Request_Info_Panel")); // this.expenseInfo = this.byId(sap.ui.core.Fragment.createId("cus.crm.mycalendar.CRM_MYCALExtension.view.AppointmentDetail_extBeforeDocHistoryCustom", "Sample_Request_Info_Panel")); if (this.transType === "ZHSP") { sap.ui.getCore().byId("Sample_Request_Info_Panel").setVisible(true); } else { // sap.ui.getCore().byId("Sample_Request_Info_Panel").setVisible(false); this.sampleInfo.setVisible(false); }
}(The expenseInfo is an element in another extension point.)
So how could I access the element in the fragment/extension point?
Regards,
Xuebin









.jpg)



