0
votes

I have the xml view (abbreviated):

<mvc:View controllerName="view.xxx" xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:control="control" xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1" xmlns:h="http://www.w3.org/1999/xhtml">
...
<HBox items="{/ResourceSet}">
<Select id="myResource" app:ResourceKey="{ResourceKey}" change="handleChange"

(/ResourceSet yields none or one entry, nether more, thus the id will always be unique)

inside the handleChange(evt) function of the controller:

evt.getSource().data()

yields correctly Object {ResourceKey: "xxxxxxx"}

this.getView().byId("myResource").data()

yields wrongly Object {ResourceKey: null}

This is not good!

Happens with at least 1.18.x and 1.20.4.

Any ideas how to access the data of an element which is not the current event source?

Regards, Wolfgang

PS http://sap.github.io/openui5/bugreports.html asks for a jsbin/gist: Is there a preferred public OData source to be used for the examples (I would be more comfortable with a NWG based source than a MS based source like http://services.odata.org/Northwind/Northwind.svc)?

1
when you call this.getView().byId("myResource").data()? is 'this' the controller? alt try sap.ui.getCore().byId("myResource").data() - Jasper_07

1 Answers

0
votes

You can retrieve the data by using forEach regardless of which is force selected, since the .data() method returns null. This will only work after view content is fully loaded.

var array = new Array();
this.getView().byId("myresources").getItems().forEach(function(element) {
  var keys = element.getKey();
  var texts = element.getText();
  var obj = new Object({
    key: keys,
    value: texts
  });
  array.push(obj);

});
console.log(array);