cancel
Showing results for 
Search instead for 
Did you mean: 

Why is my data not getting displayed in the second field after selecting any item in dialog box

Former Member
0 Kudos

I am completely new to SAPUI5. I have two input fields which have got dialog box. I have also created a fragment. For the first input field,data is getting displayed after selecting from the dialog box. But for the second field the dialog box is not getting opened.

Below is the code for my controller.js

onInit: function() {
this.Json = new sap.ui.model.json.JSONModel("model/list.json");//getting the json file
this.getView().setModel(this.Json);//setting model to controller

},
onPress : function (oEvent) {
// create value help dialog
if(this.dialog){
this.dialog=sap.ui.xmlfragment("project.Dialog",this);
}
this.dialog.setModel(this.Json);//binding the list to the dialog box
this.dialog.open();

},

_handleValueHelpClose:function(evt){
debugger
var oProject=this.getView().byId("sorg").setValue(evt.oSource.mAggregations._dialog.mAggregations.content[1].getSelectedItem().getTitle());

},

_handleValueHelpOpen:function(evt){
debugger
var cProject=this.getView().byId("dc").setValue(evt.oSource.mAggregations._dialog.mAggregations.content[1].getSelectedItem().getTitle());
},
});

Below is the code for my xml view:

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" controllerName="project.task1" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form">
<Page title="Title">
<content>
<f:SimpleForm layout="ResponsiveGridLayout" editable="true"
labelSpanXL="3" labelSpanL="3" labelSpanM="3" labelSpanS="10"
adjustLabelSpan="false" emptySpanXL="2" emptySpanL="2" emptySpanM="2"
emptySpanS="0" columnsXL="2" columnsL="2" columnsM="2">
<f:content>
<core:Title>
</core:Title>

<Label text="Sales Organization" labelFor="sorg" />
<Input id="sorg" showValueHelp="true" valueHelpRequest="onPress"
showSuggestion="true" suggestionItems="{/Collection}">
<suggestionItems>
<core:Item text="{Name}" />
</suggestionItems>
</Input>
<Label text="Distribution Channel" labelFor="dc" />
<Input id="dc" showValueHelp="true" valueHelpRequest="onPresscc"
showSuggestion="true" />

<Label text="Division" />
<Input id="div" />
<Label text="Sales Group" showValueHelp="true"
valueHelpRequest="onPress" showSuggestion="true" />
<Input id="sg" />

<core:Title>
</core:Title>
<Label text="Plant" showValueHelp="true" valueHelpRequest="onPress"
showSuggestion="true" />
<Input id="plant" />
<Label text="Sales Office" />
<Input id="soff" showValueHelp="true" valueHelpRequest="onPress"
showSuggestion="true" />
<Label text="Sold to party" />
<Input id="stp" />
<Label text="Material Number" showValueHelp="true"
valueHelpRequest="onPress" showSuggestion="true" />
<Input id="id" />
</f:content>
</f:SimpleForm>
</content>
</Page>
</core:View>

Below is my code for fragment.xml:

<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<SelectDialog
title="Select"
items="{/Collection}"
search="_handleValueHelpSearch"
confirm="_handleValueHelpClose"
cancel="_handleValueHelpClose">
<StandardListItem
title="{Name}"
description="{Designation}" />
</SelectDialog>
</core:FragmentDefinition>

Accepted Solutions (0)

Answers (1)

Answers (1)

vaibhav_gb
Explorer
0 Kudos

Hi Kshitij,

For Distribution Channel input box which has the id "dc" there is an event defined as onPresscc, however this event is not found in controller.js hence there is no SelectDialog box which is rendered.

If this is not the issue, please provide the id of the input filed to investigate it further.

regards

GB

Former Member
0 Kudos

Where in the code should I provide id of the input field?

vaibhav_gb
Explorer
0 Kudos

id of the infputfield which is causing the issue