0

I'm a beginner to SAP Fiori (UI5) and trying to retrieve a value from a table made with sap.m.Table in SAP Web IDE. But I don't succeed. Anybody hints on how to get there?

<Table id="table0" items="{/Entity1_Set}">
  <ColumnListItem detailPress=".onShowHello" type="DetailAndActive">
    <Text id="text5" maxLines="0" text="{Id}" />
    <Text id="text6" maxLines="0" text="{field1}" />
    <Text id="text7" maxLines="0" text="{field2}" />
    <Text id="text8" maxLines="0" text="Euro"/>
  </ColumnListItem>
  <columns>
    <Column id="column0">
      <Label id="label0" text="Floor"/>
    </Column>
  </columns>
</Table>
sap.ui.define([
  "sap/ui/core/mvc/Controller",
  "sap/m/MessageToast",
], function(Controller, MessageToast) {
  "use strict";

  return Controller.extend("QuickStartApplication.controller.View1", {
    onShowHello: function(){
      MessageToast.show("Hello World!");
    },

  });
});

In the "hello world"-MessageToast, I would like to display values of the fields in my table.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
zak bennani
  • 31
  • 1
  • 8
  • Does this answer your question? [Access bound data from clicked List Item in UI5 controller](https://stackoverflow.com/questions/47798252/access-bound-data-from-clicked-list-item-in-ui5-controller) – Boghyon Hoffmann Feb 02 '21 at 15:22

1 Answers1

0

You can pass parameters in the function, which is called during an event. Please see also https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.ListItemBase.html#event:detailPress

Using these parameters, you can access the bound data. Please see the following code on how to read the binding context of the ColumnListItem:

detailPress : function(oEventParams){
                var oListItem = oEventParams.getSource();
                var oBindingContext = oListItem.getBindingContext(); var sSomePropertyValue = oBindingContext.getProperty("<nameOfProperty>"); }

Using .getProperty, you can access your field values.