Somehow my filter update through the function onSearch is not updating the view. The initial Filter in the XML View is working fine. Also when sIaNr is empty the aFilter = [] is working as I'm seeing all results. But when sIaNr is not empty this part is called and the filter is not working:
aFilter.push(new Filter("raufnr", FilterOperator.EQ, sIaNr))
this is my Code
ZCATS_TESTJ.json
{
"d": {
"results": [{
"status": "30",
"skostl": "0001",
"catshours": "2.50",
"ktext": "test1",
"counter": "000003484040",
"mandt": "101",
"pernr": "00015822",
"usrid": "xx123",
"workdate": "\/Date(1477267200000)\/",
"raufnr": "6000025"
}, {
"status": "30",
"skostl": "0001",
"catshours": "8.00",
"ktext": "test2",
"counter": "000002919281",
"mandt": "101",
"pernr": "1234",
"usrid": "xx123",
"workdate": "\/Date(1441065600000)\/",
"raufnr": "0815"
}, {
"status": "30",
"skostl": "0001",
"catshours": "8.00",
"ktext": "test1",
"counter": "000002919281",
"mandt": "101",
"pernr": "00015822",
"usrid": "xx123",
"workdate": "\/Date(1441065600000)\/",
"raufnr": "6000007"
}]
}
}
List.view
<mvc:View
controllerName="sap.ui.bookedTimes.wt.controller.List"
id="listview"
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns:fb="sap.ui.comp.filterbar"
xmlns:core="sap.ui.core"
xmlns="sap.m">
<Table id="exportTable" inset="false" growing="true" growingThreshold="700" visible="true"
items="{
path : 'view>/d/results',
filters : [
{ path : 'raufnr', operator : 'EQ', value1 : '6000007'}
]
}">
<headerToolbar>
<OverflowToolbar>
<ToolbarSpacer />
<Button icon="sap-icon://excel-attachment" press="onExport"/>
</OverflowToolbar>
</headerToolbar>
<columns>
<Column>
<Text text="IA-Nummer" />
</Column>
<Column>
<Text text="Bezeichnung" />
</Column>
<Column>
<Text text="Datum" />
</Column>
<Column hAlign="End">
<Text text="Zeit" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier title="{view>raufnr}" />
<Text id="tText" text="{view>ktext}" />
<Text text="{path: 'view>workdate', type: 'sap.ui.model.type.Date', formatOptions: { pattern: 'dd.MM.yyyy' } }" />
<Text text="{view>catshours}" />
</cells>
</ColumnListItem>
</items>
</Table>
List.controller
sap.ui.define([
'jquery.sap.global',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel',
'sap/ui/core/util/MockServer',
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator",
"sap/ui/model/FilterType"
// 'sap/ui/export/Spreadsheet'
], function(jQuery, Controller, JSONModel, Filter, FilterOperator, FilterType) {
"use strict";
return Controller.extend("sap.ui.bookedTimes.wt.controller.List", {
onInit : function () {
//Get Model
var jModel = this.getOwnerComponent().getModel("zCatsTestJ");
var that = this;
//after Model is loaded transform Date
jModel.attachRequestCompleted(function() {
//var oViewModel= new JSONModel(jModel);
for (var i = 0; i< jModel.oData.d.results.length; i++){
var sJsonDate = jModel.getProperty("/d/results/" + [i] + "/workdate");
//Json Date in Datumsformat umwandeln
var sNumber = sJsonDate.replace(/[^0-9]+/g,'');
var iNumber = sNumber * 1; //trick seventeen
var oDate = new Date(iNumber);
jModel.setProperty("/d/results/" + [i] + "/workdate", oDate);
}
//update the model with new Date format
that.getView().setModel(jModel, "view");
});
},
onSearch: function(oEvent) {
// build filter array
var aFilter = [];
var oParams = oEvent.getParameter("selectionSet");
var sIaNr = oParams[0].getValue();
var oList = this.getView().byId("exportTable");
var oBinding = oList.getBinding("items");
if (sIaNr) {
aFilter.push(new Filter("raufnr", FilterOperator.EQ, sIaNr));
}
//filter binding
oBinding.filter(aFilter, FilterType.Application);
}
});
});
any help would be greatly appreciated. Thanks
Delete 'sap/ui/core/util/MockServer' in the define part.
I'm trying to bind and present an element to a detail page, but no success about it.
the master page is displayed well and present the data.
but when i want to present the item on a detail page the data doesn't displayed.
*for fetching all the data i use an API request
I'm not sure what am i doing wrong.
Heres the code:
Controller.Overview.js
var data = {id: 19265, typeId: 5, foreignKeyId: 1, foreignKeyTextId: "316e2c71-d1d1-f73c-4696-70912d6cf240", value: 0, Name: "jim"}
,{id: 19268, typeId: 5, foreignKeyId: 1, foreignKeyTextId: "316e2c71-d1d1-f73c-4696-70912d6cf240", value: 0, Name: "john"}
var newArr2 = {"Overview" : data};
oModel.setData(newArr2);
oView.setModel(oModel);
onListItemPressed : function(oEvent){
var oItem, oCtx;
oItem = oEvent.getSource();
oCtx = oItem.getBindingContext();
this.getRouter().navTo("overviewItem",{
OverviewId : oCtx.getProperty("OverviewId")
});
}
Overview.xml
<List id="dataJS" headerText="dataJS" items="{/Overview}">
<items>
<StandardListItem
title="{foreignKeyTextId}"
iconDensityAware="false"
iconInset="false"
type="Navigation"
press="onListItemPressed"/>
</items>
</List>
controller.Overviewitem.js
return BaseController.extend("com.sap.it.cs.itsupportportaladmin.controller.feedbackanalytics.OverviewItem", {
_formFragments: {},
onInit: function () {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.getRoute("overviewItem").attachMatched(this._onRouteMatched, this);
},
_onRouteMatched : function (oEvent) {
var oArgs, oView;
oArgs = oEvent.getParameter("arguments");
oView = this.getView();
oView.bindElement({
path : "/Overview(" + oArgs.OverviewId + ")",
events : {
change: this._onBindingChange.bind(this),
dataRequested: function (oEvent) {
oView.setBusy(true);
},
dataReceived: function (oEvent) {
oView.setBusy(false);
}
}
});
},
_onBindingChange : function (oEvent) {
// No data for the binding
if (!this.getView().getBindingContext()) {
this.getRouter().getTargets().display("notFound");
}
}
});
OverviewItem.xml
<mvc:View
controllerName="com.sap.it.cs.itsupportportaladmin.controller.feedbackanalytics.OverviewItem"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
xmlns:f="sap.ui.layout.form"
busyIndicatorDelay="0">
<Page
id="overviewPage"
title="{Name}"
showNavButton="true"
navButtonPress="onNavBack"
class="sapUiResponsiveContentPadding">
<content>
<Panel
id="employeePanel"
width="auto"
class="sapUiResponsiveMargin sapUiNoContentPadding">
<headerToolbar>
<Toolbar>
<Title text="{OverviewId}" level="H2"/>
<ToolbarSpacer />
<Link text="{i18n>FlipToResume}" tooltip="{i18n>FlipToResume.tooltip}" press="onShowResume" />
</Toolbar>
</headerToolbar>
</Panel>
</content>
</Page>
</mvc:View>
I see two issues:
/Overview(" + oArgs.OverviewId + ")" will not work as your model an array and not object as per code in Controller.Overview.js:
var data = {id: 19265, typeId: 5, foreignKeyId: 1, foreignKeyTextId: "316e2c71-d1d1-f73c-4696-70912d6cf240", value: 0, Name: "jim"}
,{id: 19268, typeId: 5, foreignKeyId: 1, foreignKeyTextId: "316e2c71-d1d1-f73c-4696-70912d6cf240", value: 0, Name: "john"}
var newArr2 = {"Overview" : data};
oModel.setData(newArr2);
// this resolves to :
newArr2 = {"Overview" : [ {id: 19265...}, {id: 19268...} ]}
oView.setModel(oModel);
You will have to find index of Clicked item and do :
/Overview/" + oArgs.OverviewIndex resulting in somethin like: Overview/0 or Overview/1 etc.
Also, you have set the model only to your master list.
oView.setModel(oModel); where oView is in Controller.Overview.js.
Please set the model to your complete split-app for binding context to work correctly.
===========
Update after Discussion: Store you data as an Object:
// id as the key. SO, you can easily fetch person.
var data = {
"19265" : {id: 19265, typeId: 5, foreignKeyId: 1, foreignKeyTextId: "316e2c71-d1d1-f73c-4696-70912d6cf240", value: 0, Name: "jim"},
"19268" : {id: 19268, typeId: 5, foreignKeyId: 1, foreignKeyTextId: "316e2c71-d1d1-f73c-4696-70912d6cf240", value: 0, Name: "john"}
};
And Set binding on click as:
oView.bindElement({
path : "/Overview/" + oArgs.OverviewId + "",
events : {
change: this._onBindingChange.bind(this),
dataRequested: function (oEvent) {
oView.setBusy(true);
}, ... rest of code.
I'm using PlanningCalendar App to show the workers schedule.
But what I also need is, after I click on the worker (for example 'Carlos Pinho') his data (name and role) appear on the TextBox from the SimpleForm (red arrow)
Controller:
sap.ui.define([
'jquery.sap.global',
'sap/m/StandardListItem',
'sap/m/MessageToast',
'sap/ui/core/mvc/Controller',
'sap/m/Label',
'sap/m/Text',
'sap/m/TextArea',
'sap/ui/model/json/JSONModel'], function(jQuery, StandardListItem, MessageToast, Controller, Label, Text, TextArea, JSONModel) {
"use strict";
return Controller.extend("zapp_rej_absence.controller.Main", {
onInit: function() {
//this.getView().byId() //Para definir o que aparece na combo box
// create model
var oModel = new JSONModel();
oModel.setData({
startDate: new Date("2017", "4", "26", "8", "0"),
people: [{
pic: "sap-icon://employee", //Foto do Funcionario
name: "Carlos Pinho", //Nome do Funcionario
role: "Logística", //Area do Funcionario
appointments: [{
start: new Date("2017", "4", "29", "12", "0"), //[Ano, Meses (cujo a ordem é Janeiro ->0), Dia, Horas, Minutos]
end: new Date("2017", "4", "29", "14", "0"),
title: "Reunião de Equipa",
info: "Sala A06",
type: "Type01", //Cor do Evento
pic: "sap-icon://manager",
tentative: false
}, {
start: new Date("2017", "5", "10", "0", "0"), //[Ano, Meses (cujo a ordem é Janeiro ->0), Dia, Horas, Minutos]
end: new Date("2017", "5", "16", "23", "59"),
title: "Férias",
info: "Maldivas",
pic: "sap-icon://flight",
type: "Type04", //Cor do Evento
tentative: false
}],
headers: [{
start: new Date("2017", "4", "29", "08", "0"), //[Ano, Meses (cujo a ordem é Janeiro ->0), Dia, Horas, Minutos]
end: new Date("2017", "4", "29", "10", "0"),
title: "Privado",
type: "Type05"
}]
}, {
pic: "sap-icon://employee", //Foto do Funcionario
name: "Joaquim Agostinho", //Nome do Funcionario
role: "Financeira", //Area do Funcionario
appointments: [{
start: new Date("2017", "4", "29", "08", "30"), //[Ano, Meses (cujo a ordem é Janeiro ->0), Dia, Horas, Minutos]
end: new Date("2017", "4", "29", "09", "30"),
title: "Reunião",
pic: "sap-icon://world",
type: "Type02", //Cor do Evento
tentative: false
}, {
start: new Date("2017", "4", "30", "10", "0"), //[Ano, Meses (cujo a ordem é Janeiro ->0), Dia, Horas, Minutos]
end: new Date("2017", "4", "30", "12", "0"),
title: "Reunião de Equipa",
info: "Sala 1",
type: "Type01", //Cor do Evento
pic: "sap-icon://manager",
tentative: false
}, {
start: new Date("2017", "4", "30", "12", "30"), //[Ano, Meses (cujo a ordem é Janeiro ->0), Dia, Horas, Minutos]
end: new Date("2017", "4", "30", "13", "30"),
title: "Almoço",
type: "Type03", //Cor do Evento
pic: "sap-icon://meal",
tentative: true
}],
headers: [{
start: new Date("2017", "4", "29", "8", "0"), //[Ano, Meses (cujo a ordem é Janeiro ->0), Dia, Horas, Minutos]
end: new Date("2017", "4", "29", "10", "0"),
title: "Lembrete",
type: "Type06" //Cor do Evento
}]
}]
});
this.getView().setModel(oModel);
},
//Dialog do botão aceitar
onMessageSuccessDialogPress: function(oEvent) {
var dialog = new Dialog({
title: 'Successo',
type: 'Message',
state: 'Success',
content: new Text({
text: "Foi aprovado com sucesso."
}),
beginButton: new Button({
text: 'OK',
press: function() {
MessageToast.show('Pedido Aprovado');
dialog.close();
}
}),
afterClose: function() {
dialog.destroy();
}
});
dialog.open();
},
onMessageWarningDialogPress: function(oEvent) {
var dialog = new Dialog({
title: 'Aviso',
type: 'Message',
state: 'Warning',
content: new Text({
text: 'Tem a certeza que quer rejeitar este pedido?'
}),
beginButton: new Button({
text: 'Sim',
press: function() {
dialog.close();
var dialog1 = new Dialog({
title: 'Confirmação',
type: 'Message',
content: [
new Label({
text: 'Tem a certeza que pretende rejeitar o pedido?',
labelFor: 'submitDialogTextarea'
}),
new TextArea('submitDialogTextarea', {
liveChange: function(oEvent) {
var sText = oEvent.getParameter('value');
var parent = oEvent.getSource().getParent();
parent.getBeginButton().setEnabled(sText.length > 0);
},
width: '100%',
placeholder: 'Adicionar nota (obrigatória)'
})
],
beginButton: new Button({
text: 'Submit',
enabled: false,
press: function() {
MessageToast.show('Pedido Rejeitado');
dialog1.close();
}
}),
endButton: new Button({
text: 'Cancel',
press: function() {
dialog1.close();
}
}),
afterClose: function() {
dialog1.destroy();
}
});
dialog1.open();
}
}),
endButton: new Button({
text: 'Não',
press: function() {
dialog.close();
}
}),
afterClose: function() {
dialog.destroy();
}
});
dialog.open();
},
onSubmitDialog: function() {
var dialog = new Dialog({
title: 'Confirm',
type: 'Message',
content: [
new Label({
text: 'Are you sure you want to submit your shopping cart?',
labelFor: 'submitDialogTextarea'
}),
new TextArea('submitDialogTextarea', {
liveChange: function(oEvent) {
var sText = oEvent.getParameter('value');
var parent = oEvent.getSource().getParent();
parent.getBeginButton().setEnabled(sText.length > 0);
},
width: '100%',
placeholder: 'Add note (required)'
})
],
beginButton: new Button({
text: 'Submit',
enabled: false,
press: function() {
var sText = sap.ui.getCore().byId('submitDialogTextarea').getValue();
MessageToast.show('Note is: ' + sText);
dialog.close();
}
}),
endButton: new Button({
text: 'Cancel',
press: function() {
dialog.close();
}
}),
afterClose: function() {
dialog.destroy();
}
});
dialog.open();
},
onMessageDialogPress: function(oEvent) {
var dialog = new Dialog({
title: 'Meses Aprovados',
icon: 'sap-icon://calendar',
type: 'Message',
content: new Text({
text: 'A ideia é aparecer os meses todos em RadioButtons'
}),
beginButton: new Button({
text: 'OK',
press: function() {
dialog.close();
}
}),
endButton: new Button({
text: 'Cancelar',
press: function() {
dialog.close();
}
}),
afterClose: function() {
dialog.destroy();
}
});
dialog.open();
},
handlePopoverPress: function(oEvent) {
// create popover
if (!this._oPopover) {
this._oPopover = sap.ui.xmlfragment("zapp_rej_absence.view.Popover", this);
this.getView().addDependent(this._oPopover);
this._oPopover.bindElement("/ProductCollection/0");
}
// delay because addDependent will do a async rerendering and the actionSheet will immediately close without it.
var oButton = oEvent.getSource();
jQuery.sap.delayedCall(0, this, function() {
this._oPopover.openBy(oButton);
});
},
//---------------------------------------------------------Eventos
handleAppointmentSelect: function(oEvent) {
var oAppointment = oEvent.getParameter("appointment"); //Selecçao do Evento
if (oAppointment) {
alert("Evento Selecionado: " + oAppointment.getTitle());
} else {
var aAppointments = oEvent.getParameter("appointments");
var sValue = aAppointments.length + " Eventos Selecionados";
alert(sValue);
}
}
}); });
XML:
<mvc:View controllerName="zapp_rej_absence.controller.Main" xmlns:html="http://www.w3.org/1999/xhtml" displayBlock="true" xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc" xmlns:unified="sap.ui.unified" xmlns:f="sap.ui.layout.form">
<Page title="Aprovação de Férias/Ausências" enableScrolling="true">
<Panel class="sapUiSmallMargin" width="auto">
<PlanningCalendar id="PC1" startDate="{path: '/startDate'}" rows="{path: '/people'}" appointmentsVisualization="Filled"
appointmentSelect="handleAppointmentSelect" showEmptyIntervalHeaders="false" viewKey="One Month">
<toolbarContent>
<Title text="Calendário" titleStyle="H4"/>
<ToolbarSpacer/>
<SearchField width="300px" placeholder="Procurar..."/>
<Button icon="sap-icon://legend" press="handlePopoverPress"/>
</toolbarContent>
<rows>
<PlanningCalendarRow icon="{pic}" title="{name}" text="{role}" appointments="{appointments}" intervalHeaders="{headers}">
<appointments>
<unified:CalendarAppointment startDate="{start}" endDate="{end}" icon="{pic}" title="{title}" text="{info}" type="{type}"
tentative="{tentative}"></unified:CalendarAppointment>
</appointments>
<intervalHeaders>
<unified:CalendarAppointment startDate="{start}" endDate="{end}" icon="{pic}" title="{title}" type="{type}"></unified:CalendarAppointment>
</intervalHeaders>
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
<f:SimpleForm id="SimpleFormDisplay354" class="sapUiLargeMarginTop" width="auto" editable="false" layout="ResponsiveGridLayout"
title="Informações do Colaborador" labelSpanXL="3" labelSpanL="3" labelSpanM="3" labelSpanS="12" adjustLabelSpan="false" emptySpanXL="4"
emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1" singleContainerFullSize="false">
<f:content>
<Label text="Nome" width="100%" design="Bold"/>
<Text text="{Name}" width="100%"/>
<!--Depois ir buscar estes dados à BD-->
<Label text="Equipa" width="100%" design="Bold"/>
<Text text="{Street} {HouseNumber}" width="100%"/>
<!--Depois ir buscar estes dados à BD-->
<Label text="Total de Férias" width="100%" design="Bold"/>
<Text text="{ZIPCode} {City}" width="100%"/>
<!--Depois ir buscar estes dados à BD-->
<Label text="Country" width="100%" design="Bold"/>
<Text text="{Country}" width="100%"/><!--Depois ir buscar estes dados à BD--></f:content>
</f:SimpleForm>
</Panel>
<footer>
<Toolbar>
<Button icon="sap-icon://past" text="Meses Aprovados" type="Emphasized" press="onMessageDialogPress"/>
<ToolbarSpacer/>
<Button icon="sap-icon://accept" text="Aprovar" type="Accept" press="onMessageSuccessDialogPress"/>
<Button icon="sap-icon://sys-cancel-2" text="Rejeitar" type="Reject" press="onMessageWarningDialogPress" />
</Toolbar>
</footer>
</Page>
Thanks in advance for your help.
I used the binding context of selected row and bound it to the form below and it worked.
Below is the working code and steps:
Add "Row Selection Event" to planning calender.
<PlanningCalendar id="PC1" startDate="{path: '/startDate'}" rows="{path: '/people'}"
appointmentsVisualization="Filled"
appointmentSelect="handleAppointmentSelect" showEmptyIntervalHeaders="false" viewKey="One Month"
rowSelectionChange="onRowSelection">
Step 2: Find the binding Context of selected row and bind it to the form:
onRowSelection: function(oEvent) {
var oForm = this.byId('SimpleFormDisplay354');
var oBindingContext = oEvent.getSource().getSelectedRows()[0].getBindingContext();
oForm.setBindingContext(oBindingContext);
}
Step 3: Bind correct Properties in the form:
<f:SimpleForm id="SimpleFormDisplay354" class="sapUiLargeMarginTop" width="auto" editable="false" layout="ResponsiveGridLayout"
title="Informações do Colaborador" labelSpanXL="3" labelSpanL="3" labelSpanM="3" labelSpanS="12" adjustLabelSpan="false" emptySpanXL="4"
emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1" singleContainerFullSize="false">
<f:content>
<Label text="Nome" width="100%" design="Bold"/>
<Text text="{name}" width="100%"/>
<!--Depois ir buscar estes dados à BD-->
<Label text="Role" width="100%" design="Bold"/>
<Text text="{role}" width="100%"/>
</f:content>
</f:SimpleForm>
Let me know if this works for you.
A select element is a dropdown list in which an option may be selected.
The select element has the selectedItem which is a handle to the currently selected item. A selected item has a key that I bind to an identifying attribute in my JSON model.
Using an XML view declaration, I can use the change() event to fire code in the controller.
In the change() event how can I get the binding path of the selectedItem without having to search the model to match the key?
This is what I intuited but the second line throws an error.
onListSelect : function(event) {
console.log(event.oSource.getSelectedItem().getKey()) // works ok
var path = event.oSource.getSelectedItem().getBindingContext().getPath(); // Fails
}
EDIT: In response to input & comments I added the snippet to isolate the issue. In the course of doing so I find that there is no issue. The snippet works. Must have been my own mistake.
I shall erase the question shortly.
// JSON sample data
var data = {
"peeps": [
{className: "Coding 101", id: 100, firstName: "Alan", lastName: "Turing"},
{className: "Coding 101", id: 400, firstName: "Ada", lastName: "Lovelace"},
{className: "Combat 101", id: 300, firstName: "D", lastName: "Trump"},
{className: "Combat 101", id: 700, firstName: "Spartacus", lastName: ""},
{className: "Combat 101", id: 900, firstName: "Tasmanian", lastName: "Devil"}
]
};
sap.ui.getCore().attachInit(function() {
"use strict";
sap.ui.controller("MyController", {
onInit: function() {
// create JSON model instance
var oModel = new sap.ui.model.json.JSONModel();
// set the data for the model
oModel.setData(data);
// set model to core.
sap.ui.getCore().setModel(oModel);
},
onListSelect : function(event) {
console.log(event.getSource().getSelectedItem().getKey()); // works ok
var path = event.getSource().getSelectedItem().getBindingContext().getPath(); // Fails
console.log("Path=" + path)
var oModel = sap.ui.getCore().getModel()
var theName = oModel.getProperty(path)
console.log("You selected " + theName.lastName)
}
});
sap.ui.xmlview({
viewContent: jQuery("#myView").html()
}).placeAt("content");
});
<!DOCTYPE html>
<title>SAPUI5</title>
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m" data-sap-ui-bindingSyntax="complex" data-sap-ui-compatVersion="edge" data-sap-ui-preload="async"></script>
<script id="myView" type="ui5/xmlview">
<mvc:View controllerName="MyController" xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:layout="sap.ui.commons.layout" xmlns:f="sap.ui.layout.form">
<Select id="theList" forceSelection="false" wisth="auto" change="onListSelect" items="{
path: '/peeps',
sorter: { path: 'lastName' }
}" class="sapUiResponsiveMargin">
<core:Item key="{id}" text="{lastName}" />
</Select>
</mvc:View>
</script>
<body class="sapUiBody">
<div id="content"></div>
</body>
Check following XML and JS code :
XML Code :
`<Select id="id_Select"
forceSelection="false"
selectedKey="{/Data/0/key}"
change="fnSelectChange"
items="{/Data}" >
<core:Item key="{key}" text="{name}" />
</Select>`
JS Code :
fnInputHandel : function(){
oSelectJSON = new sap.ui.model.json.JSONModel();
var Data = {
Data : [{
name : "name1",
key : "key1"
},{
name : "name2",
key : "key2"
}]
}
oSelectJSON.setData(Data);
this.getView().byId("id_Select").setModel(oSelectJSON);
},
fnSelectChange : function(oEvent){
var value = oEvent.oSource.getSelectedItem().getBindingContext().getPath();
},