cancel
Showing results for 
Search instead for 
Did you mean: 

UI5 Dialog Fragment - Smart Input and Element Binding doesn't work

bbalci
Contributor
0 Kudos

I need a fragment dialog for entering / editing fields belong to an entity in my project, but I also need Input / Value Helps for the fields on the fragment. So I tried to use SmartFields for it.

I'm trying to use element binding on a dialog fragment which includes Smart Fields, it's not working, can anyone tell me what's wrong in following steps :

For SmartForm and SmartFields I found this example on DemoKit : Smart Field , in this example element binding on the view is simply done by this command :

onInit: function () {
  var oView = this.getView();
  oView.bindElement("/Products('1239102')");
}<br>

I tried to do the same on my fragment, fragment XML code is below , I just copied SmartForm and SmartField components from the examples in DemoKit. "Title" and "MeetupType" fields are existing fields in my Mock Server's EntitySet with name "Meetups" :

<core:FragmentDefinition 
	xmlns="sap.m" 
	xmlns:core="sap.ui.core" 
	xmlns:form="sap.ui.comp.smartform" 
	xmlns:smartField="sap.ui.comp.smartfield" 		
>
   <Dialog  id="dialogMeetupEdit"  title="Edit meeting :">

   	<content>
	<form:SmartForm id="SF1" class="editableForm" editTogglable="true" editable="true" title="{Name}">
		<form:Group id="G1" label="SmartField with ValueHelp">

			<form:GroupElement id="GE-Title">
				<smartField:SmartField id="idTitle" value="{Title}"/>
			</form:GroupElement>

			<form:GroupElement id="GE-MeetupType">
				<smartField:SmartField id="idMeetupType" value="{MeetupType}"/>
			</form:GroupElement>	   			
   
		</form:Group>
	</form:SmartForm>	   	
   	</content>
   	
   	<beginButton>  <Button text="Save" /> </beginButton>
   	<endButton> <Button text="Cancel" type="Reject" press="closeMeetupDialog"/> </endButton>
   			
   </Dialog>
</core:FragmentDefinition>
In controller, before opening the fragment , I try to make element binding as below :
 onAddEntry: function(oEvent){
   var lo_dialog = this.getMeetupEditDialog(this);					
   lo_dialog.bindElement("/Meetups('1')");			
   lo_dialog.open();					
},

getMeetupEditDialog : function(ip_this) {
  ip_this.meetupEditDialog = sap.ui.getCore().byId("dialogMeetupEdit");
	
  if (!ip_this.meetupEditDialog)
   {
     ip_this.meetupEditDialog = sap.ui.xmlfragment("MyProject.fragments.meetupEdit", ip_this); 
     ip_this.getView().addDependent(ip_this.meetupEditDialog);	
     jQuery.sap.syncStyleClass("sapUiSizeCompact",  ip_this.getView(), ip_this.meetupEditDialog);
    }	
     return ip_this.meetupEditDialog;
},
My purpose is creating an entry / edit dialog for the entity fields with Input Helps set by annotations. If there is any other proper way to do this , that can also be an answer to my question.Thanks in advance
View Entire Topic
junwu
Active Contributor
0 Kudos

"doesn't work" means what? for now it means nothing...

bbalci
Contributor
0 Kudos

Hi Jun,

Sorry I didn't explain it well, when fragment opens up , SmartFields are not even rendered & visible on it. I see just an empty fragment.