cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 web ide odata collect and input to select zone

former_member202213
Participant
0 Kudos

Hi Everyone,

i'm trying the following :

when opening a form, I need to use Odata to set value to a select zone.

i succeed in modifying selected key but data displayed are unchanged. what do I have to do to have displayed data corresponding to selectedkey ?

you may find following : the code for the select zone in view :

							<Select xmlns="sap.m" id="select0" items="{path: 'tableData>/ZisuRTypeGeneSet', templateShareable:false, events: {dataReceived: '.onCountriesUpdateFinished'}}" selectedKey="{tableData>ZisuTypeGenerateur}/{tableData>Designation}" cd:w5g.dt.context="tableData>/ZisuRTypeGeneSet">
								<items>
									<core:Item xmlns:core="sap.ui.core" key="{tableData>ZisuTypeGenerateur}/{tableData>Designation}" text="{tableData>ZisuTypeGenerateur}/{tableData>Designation}" id="item2"/>
								</items>
							</Select>

I used an event linked to the items in order to pass data to screen after retrieving data from Odata

in controller I have the following :

		onCountriesUpdateFinished: function (event) {
			debugger;
			// contient le contrat lié à la page (voir routing du controller function init)
			var sPath = this.getView().byId("it_item").getBinding("pages").aKeys[0];
			var oModel = this.getView().getModel("tableData"); //var reasonForUpdate = event.getParameter("TypeGenerate");
			var oTypeGenerateur = oModel.getProperty("/" + sPath + "/TypeGenerateur");
			this.getView().byId("select0").setSelectedKey("/ZisuRTypeGeneSet('" + oTypeGenerateur + "')");
		},

in my example, data i try to bind has key "TAC" oTypeGenerater = "TAC".

in the screen, selectedKey remains /ZisuRTypeGeneSet('TAC') but

key and description from screen still display initial data : MAG/Moteur A Gaz

could you help me, please ?

Accepted Solutions (1)

Accepted Solutions (1)

former_member202213
Participant
0 Kudos

Dear Timo,

thanks for your information, I succeeded today with the following way :

	// contient le contrat lié à la page (voir routing du controller function init)
	var sPath = this.getView().byId("it_item").getBinding("pages").aKeys[0];
	var oModel = this.getView().getModel("tableDataBis");
	//var reasonForUpdate = event.getParameter("TypeGenerate");
	var oTypeGenerateur = oModel.getProperty("/" + sPath + "/TypeGenerateur");
	var oDesignation = oModel.getProperty("/ZisuRTypeGeneSet('" + oTypeGenerateur + "')/Designation");
this.getView().byId("select0").setSelectedKey("/ZisuRTypeGeneSet('" + oTypeGenerateur + "')");
this.getView().getModel("tableDataBis").setProperty("/" + this.getView().byId("it_item").getBinding("pages").aKeys[0] +
				"/ZisuTypeGenerateur", oTypeGenerateur + "/" + oDesignation);

The syntax is really complicated but it works. thanks for your answer.

without the specification /Designation, it doesn't work.

Answers (1)

Answers (1)

beanonradar
Explorer
0 Kudos

Hi Jean-Francois,

If the property "selectedKey" in your view of "Select" is set to the corresponding key it should work already.

The second option is your event-script. Here I see a problem with the value passed to the setSelectedKey function. It must be the evaluated value of the path and not the path itself. Something like:

var myKey = oModel.getProperty("/ZisuRTypeGeneSet('" + oTypeGenerateur + "')");
this.getView().byId("select0").setSelectedKey(myKey);