Hey,
I try to use a table with JSON data, but my table is still after few attempts (using examples from internet) empty.
I hope you can find my mistake(s)
Here is my code:
<!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8"> <title>Rechtschreibprüfung</title> <script id="sap-ui-bootstrap" src="https://cloudportaltrial-p1941901642trial.hanatrial.ondemand.com/ui5-dist/resources/sap-ui-core.js" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m" data-sap-ui-compatVersion="edge" data-sap-ui-preload="async" data-sap-ui-xx-bindingSyntax="complex" data-sap-ui-resourceroots='{ "sap.ui.demo.wt": "./" }'> </script> <link rel="stylesheet" type="text/css" href="style.css"> <script> sap.ui.getCore().attachInit(function () { sap.ui.xmlview({ viewName: "sap.ui.demo.wt.view.App" }).placeAt("content"); }); </script> </head> <body class="sapUiBody" id="content"> </body> </html>
<mvc:View controllerName="sap.ui.demo.wt.controller.App" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:l="sap.ui.layout" xmlns:core="sap.ui.core"> <l:VerticalLayout width="100%" > <l:content> <Button text="Prüfung" press="checkText" id = "startButton" width = "auto" class="sapUiResponsiveMargin"> </Button> <Panel class="sapUiResponsiveMargin" width = "auto" id="panel2"> <headerToolbar> <Toolbar> <Title level="H2" text="Vorschläge" /> </Toolbar> </headerToolbar> <Table id="suggestionTable" items="{path:'/suggestionData'}"> <columns> <Column> <Label text="Wort"></Label> </Column> <Column> <Label text="Vorschläge"></Label> </Column> </columns> <items> <ColumnListItem> <cells> <ObjectIdentifier title="{WORD}" text="{WORD}"></ObjectIdentifier> </cells> <Text text="{SUGGESTION}"></Text> </ColumnListItem> </items> </Table> </Panel> </l:content> </l:VerticalLayout> </mvc:View>
sap.ui.define([ "sap/ui/core/mvc/Controller", "sap/m/MessageToast" ], function(Controller, MessageToast) { "use strict"; return Controller.extend("sap.ui.demo.wt.controller.App", { checkText: function() { var here = this; here.getWhitelist(); here.getCorrections(); here.createSuggestionTable(); }, createSuggestionTable: function() { var oData={ suggestionData:[{ 'WORD':"test1", 'SUGGESTION':"...test..." },{ 'WORD':"test2", 'SUGGESTION':"...test..." }] }; var demoJSONModel = new sap.ui.model.json.JSONModel(); demoJSONModel.setData(oData); sap.ui.getCore().getElementById("suggestionTable").setModel(demoJSONModel); } }); });
Thanks in advance 😊
Tim
Discussion successfully moved from SAP HANA Cloud Platform Developer Center to SAPUI5 Developer Center
as the more appropriate community for this question and status reset to Not Answered from Assumed Answered (which should not be used).
Regards, Mike (Moderator)
SAP Technology RIG
Add a comment