Dialog doesn't bring the json data like it does in the view [duplicate] - sapui5

This question already has answers here:
Dialog not displaying propagated model data
(3 answers)
Closed 17 days ago.
I'm not able to display the data of the row of a table through dialog (fragment), following images of the code and a print of the screen.
I can't identify what could be wrong. When selecting the edit icon of a table row, a dialog opens with empty input fields without bringing the value of the selected row.
//MAIN VIEW
<core:View
xmlns:core="sap.ui.core"
xmlns:l="sap.ui.layout"
xmlns:model="sap.ui.model"
xmlns="sap.m"
height="100%"
xmlns:mvc="sap.ui.core.mvc"
xmlns:tnt="sap.tnt"
xmlns:sing="MyUI5WebApp.controls.signature"
xmlns:custom="MyUI5WebApp.controls"
xmlns:quillEditor="MyUI5WebApp.controls.quill"
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
controllerName="MyUI5WebApp.src.pages.listaTarefas.ListaTarefas">
<Page title="{i18n>Commom.ListaTarefas}" >
<content>
<Table id="idTasksTable"
mode="Delete"
delete="handleDelete"
selectionChange="onSelectionChange"
items="{/}">
<headerToolbar>
<OverflowToolbar>
<content>
<Title text="{i18n>Commom.ListaTarefas}" level="H2"/>
<ToolbarSpacer />
<SearchField id="searchField" width="auto" search=".searchTasks" />
</content>
</OverflowToolbar>
</headerToolbar>
<infoToolbar>
</infoToolbar>
<columns>
<Column
hAlign="Start">
<Text text="{i18n>Commom.Edit}" />
</Column>
<Column
hAlign="Center">
<Text text="{i18n>Commom.Identificador}" enableEdit="{settings>/enableEdit}"/>
</Column>
<Column
id="title"
minScreenWidth="Tablet"
hAlign="Center"
demandPopin="true">
<Text text="{i18n>Commom.Desc}"/>
</Column>
<Column
minScreenWidth="Tablet"
demandPopin="true"
hAlign="Center">
<Text text="{i18n>Commom.status}"/>
</Column>
</columns>
<items>
<ColumnListItem vAlign="Middle">
<cells>
<ToggleButton icon="sap-icon://edit" press=".onOpenDialog" />
<ObjectIdentifier
text="{id}"/>
<Text
text="{title}"/>
<Text
text="{completed}" />
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
</core:View>
//DIALOG
`<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:model="sap.ui.model"
xmlns:f="sap.ui.layout.form">
<Dialog title="Selected Data" id="helloDialog" items="{/}">
<content>
<f:SimpleForm id="SimpleFormDisplay354"
minWidth="1024"
maxContainerCols="2"
editable="false"
layout="ResponsiveGridLayout"
labelSpanL="3"
labelSpanM="3"
emptySpanL="4"
emptySpanM="4"
columnsL="1"
columnsM="1"
>
<f:content>
<Label text="id" />
<Input value="{id}"/>
<Label text="title" />
<Input value="{title}" />
<Label text="completed" />
<Input value="{completed}" />
</f:content>
</f:SimpleForm>
</content>
<buttons>
<Button text="OK" press="onButtonPress" />
</buttons>
</Dialog>
</core:FragmentDefinition>`
//CONTROLLER
`sap.ui.define(
[
"MyUI5WebApp/src/app/BaseController",
"sap/m/MessageToast",
'MyUI5WebApp/model/RestModel',
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator",
"sap/ui/core/Fragment",
"sap/base/util/deepExtend",
"MyUI5WebApp/model/formatter"
],
function (BaseController, MessageToast, RestModel, Filter, FilterOperator, Fragment, deepExtend, Formatter) {
"use strict";
return BaseController.extend("MyUI5WebApp.src.pages.listaTarefas.ListaTarefas", {
_oDialog: null,
onInit : function () {
this.listModel = this.createRestModel("todos");
this.listModel.get();
this.getView().setModel(this.listModel);
},
searchTasks: function (oEvent) {
var aFilter = [];
var sQuery = oEvent.getParameter("query");
if (sQuery) {
aFilter.push(new Filter("title", FilterOperator.Contains, sQuery));
}
var oList = this.byId("idTasksTable");
var oBinding = oList.getBinding("items");
oBinding.filter(aFilter);
},
onOpenDialog : function (oEvent) {
var oSelectedItem = oEvent.getSource().getParent();
var oBindingContext = oSelectedItem.getBindingContext();
if (!this._oDialog) {
this._oDialog = sap.ui.xmlfragment("MyUI5WebApp.src.pages.listaTarefas.Dialog", this);
}
this._oDialog.setBindingContext(oBindingContext);
this._oDialog.open();
},
onButtonPress: function(oEvent){
var oDialog = oEvent.getSource().getParent();
oDialog.close();
},
handleDelete: function(oEvent) {
oEvent.getSource().removeItem(oEvent.getParameter("listItem"));
},
});
});`

Answer:
onOpenDialog: function (oEvent) {
var oSelectedItem = oEvent.getSource().getParent();
var oBindingContext = oSelectedItem.getBindingContext();
if (!this._oDialog) {
this._oDialog = sap.ui.xmlfragment("MyUI5WebApp.src.pages.listaTarefas.Dialog", this);
}
this.getView().addDependent(this._oDialog);
this._oDialog.setBindingContext(oBindingContext);
this._oDialog.open();
},

Related

How do I drag and drop with in one table in UI5?

I noticed on the documentation you can drag and drop between two tables https://sapui5.hana.ondemand.com/#/entity/sap.m.Table/sample/sap.m.sample.TableDnD.
But is there a way to drag and drop on the one table (same table). I have written the code for drag and drop but the drag and drop event isn't triggered when I try to drop in the same table.
<mvc:View controllerName="ariba.cso.kaarecommendation.controller.Recommendation" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core" xmlns:f="sap.f" xmlns:dnd="sap.ui.core.dnd">
<f:DynamicPage id="dynamicPageId">
<f:title>
<f:DynamicPageTitle>
<f:heading>
<Title text="{i18n>appSubTitle}"/>
</f:heading>
<f:actions>
<Button text="{i18n>presentation}" press="onPress"></Button>
<Link id="linkid" visible="false" text="{i18n>download}" href="{/powerpoint}" press="linkPress"/>
</f:actions>
</f:DynamicPageTitle>
</f:title>
<f:content>
<Table id="tableid" items="{private}" width="auto" mode="MultiSelect">
<columns>
<Column demandPopin="false" width="auto" hAlign="Begin">
<Text text="{i18n>recommendation}"/>
</Column>
<Column minScreenWidth="Small" demandPopin="true" popinDisplay="Inline" hAlign="Begin">
<Text text="{i18n>itemid}"/>
</Column>
<Column minScreenWidth="Small" demandPopin="true" popinDisplay="Inline" hAlign="Begin">
<Text text="{i18n>areas}"/>
</Column>
<Column minScreenWidth="Small" demandPopin="true" popinDisplay="Inline" hAlign="Begin">
<Text text="{i18n>regions}"/>
</Column>
<Column minScreenWidth="Small" demandPopin="true" popinDisplay="Inline" hAlign="Begin">
<Text text="{i18n>url}"/>
</Column>
</columns>
<dragDropConfig>
<dnd:DragInfo groupName="itemsgroup" sourceAggregation="items"/>
<dnd:DropInfo groupName="dragdrop" drop="onDragDrop"/>
</dragDropConfig>
<items>
<ColumnListItem>
<cells>
<Text text="{private}"/>
<Text text="{private}"/>
<Text text="{private}"/>
<Text text="{private}"/>
<Link href="{private}" text="{i18n>urltext}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</f:content>
</f:DynamicPage>
</mvc:View>
onDragDrop: function () {
var oSwap = this.byId("tableid").getSelectedItems()
if (oSwap.length !== 2) {
var bCompact = !!this.getView().$().closest(".sapUiSizeCompact").length;
MessageBox.error(
"Please pick two items.", {
styleClass: bCompact ? "sapUiSizeCompact" : ""
}
);
}
else{
var jObject = JSON.parse(this.getModel("table").getJSON());
var first = JObject.indexOf()
var second = JObject.indexOf()
jObject[first] =
jObject[second] =
this.setModel(new JSONModel(jObject), "table");
}
}
Try this:
<dnd:DragInfo sourceAggregation="items"/>
<dnd:DropInfo drop="onDragDrop" targetAggregation="items" dropPosition="Between" dropLayout="Vertical"/>
You can refer to this example in the SDK for further info

Highlight selected row of table in SAP UI5

I am using sap.m.table with mode "SingleSelectLeft" and with Aggregation ColumnListItem of type "Navigation".
On clicking of any of the items from the table, I want to show another page in split-app(detail page). I have put the routing code in the press event of ColumnListItem but this is leading to an issue as :
The selected item goes off(not appearing selected) when I click on the detail page.
Here is the snippet I am working with:
<Table inset="false" noDataText="{i18n>noDataMasterTable}" mode="SingleSelectLeft" selectionChange="onLineItemSelected" id="s2-table"
updateFinished="onListUpdateFinished" items="{mainService>/Bp}" busyIndicatorDelay="{detailView>/lineItemTableDelay}"
itemPress="handleMasterPress" width="100%" >
<headerToolbar>
<OverflowToolbar>
<SearchField id="s2-searchfield-search" tooltip="{i18n>searchToolTip}" liveChange="onSearch" width="auto"></SearchField>
<Button id="s2-table-activate" text="Activate" press="handleActivateBusinessPurpose" enabled="false"/>
<Button id="s2-table-delete" text="{i18n>delete}" press="handleDelete" enabled="false"/>
<Button id="s2-table-add" icon="sap-icon://add" press="handleCreatePress" tooltip="{i18n>addToolTip}"/>
</OverflowToolbar>
</headerToolbar>
<columns>
<Column >
<Text text="{i18n>Name}"/>
</Column>
<Column>
<Text text="{i18n>ApplicationGroupName}"/>
</Column>
<Column demandPopin="true" minScreenWidth="Tablet">
<Text text="{i18n>DataSubjectType}"/>
</Column>
<Column demandPopin="true" minScreenWidth="Tablet">
<Text text="{i18n>LegalEntity}"/>
</Column>
<Column demandPopin="true" minScreenWidth="Tablet">
<Text text="{i18n>Status}"/>
</Column>
</columns>
<items>
<ColumnListItem type="Navigation" press="handleMasterPress">
<!--<ColumnListItem >-->
<cells>
<ObjectIdentifier title="{mainService>BusinessPurposeName}"/>
<ObjectIdentifier text="{mainService>ApplicationGroupName}"/>
<ObjectIdentifier text="{mainService>DataSubjectType}"/>
<ObjectIdentifier text="{mainService>LegalEntityValue}"/>
<ObjectStatus text="{path:'mainService>Status', formatter:'.formatPurposeStatus'}"
state="{path:'mainService>Status', formatter:'.formatStatusColor'}"/>
</cells>
</ColumnListItem>
</items>
</Table>
Please let me know how can I show the selected item highlighted in the table.
First, you are firing 2 event on pressing and handling them with the same function. So, delete itemPress="handleMasterPress" or use another funtion.
Then, handleMasterPress() will be executed by the <ColumnListItem type="Navigation" press="handleMasterPress">
So in the handler, get the source from the event object and pass it to the table in the setSelectedItem() function
handleMasterPress: function(oEvent){
var oColumnListItem = oEvent.getSource();
var oTable = oColumnListItem.getParent();
oTable.setSelectedItem(oColumnListItem);
}
Here a working snippet
// define a new (simple) Controller type
sap.ui.controller("my.own.controller", {
handleMasterPress: function(oEvent){
var oColumnListItem = oEvent.getSource();
console.log(oColumnListItem.getMetadata())
var oTable = oColumnListItem.getParent();
oTable.setSelectedItem(oColumnListItem);
}
});
// instantiate the View
var myView = sap.ui.xmlview({viewContent:jQuery('#view1').html()}); // accessing the HTML inside the script tag above
// create some dummy JSON data
var data = {
WaybillsPlaces: [{
CoNumber: "Item 1",
},{
CoNumber: "Item 2",
},{
CoNumber: "Item 3",
}]
};
// create a Model and assign it to the View
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(data);
myView.setModel(oModel, "mainService");
// put the View onto the screen
myView.placeAt('content');
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta charset="utf-8">
<title>MVC with XmlView</title>
<!-- Load UI5, select "blue crystal" theme and the "sap.m" control library -->
<script id='sap-ui-bootstrap'
src='https://sapui5.hana.ondemand.com/resources/sap-ui-core.js'
data-sap-ui-theme='sap_bluecrystal'
data-sap-ui-libs='sap.m'
data-sap-ui-xx-bindingSyntax='complex'></script>
<!-- DEFINE RE-USE COMPONENTS - NORMALLY DONE IN SEPARATE FILES -->
<!-- define a new (simple) View type as an XmlView
- using data binding for the Button text
- binding a controller method to the Button's "press" event
- also mixing in some plain HTML
note: typically this would be a standalone file -->
<script id="view1" type="sapui5/xmlview">
<mvc:View
controllerName="my.own.controller"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Panel headerText="Table Panel">
<Table inset="false" noDataText="{i18n>noDataMasterTable}" mode="SingleSelectLeft" selectionChange="onLineItemSelected" id="s2-table"
updateFinished="onListUpdateFinished" items="{mainService>/WaybillsPlaces}" busyIndicatorDelay="{detailView>/lineItemTableDelay}"
width="100%" >
<headerToolbar>
<OverflowToolbar>
<SearchField id="s2-searchfield-search" tooltip="{i18n>searchToolTip}" liveChange="onSearch" width="auto"></SearchField>
<Button id="s2-table-activate" text="Activate" press="handleActivateBusinessPurpose" enabled="false"/>
<Button id="s2-table-delete" text="{i18n>delete}" press="handleDelete" enabled="false"/>
<Button id="s2-table-add" icon="sap-icon://add" press="handleCreatePress" tooltip="{i18n>addToolTip}"/>
</OverflowToolbar>
</headerToolbar>
<columns>
<Column >
<Text text="{i18n>Name}"/>
</Column>
<Column>
<Text text="{i18n>ApplicationGroupName}"/>
</Column>
<Column demandPopin="true" minScreenWidth="Tablet">
<Text text="{i18n>DataSubjectType}"/>
</Column>
<Column demandPopin="true" minScreenWidth="Tablet">
<Text text="{i18n>LegalEntity}"/>
</Column>
<Column demandPopin="true" minScreenWidth="Tablet">
<Text text="{i18n>Status}"/>
</Column>
</columns>
<items>
<ColumnListItem type="Active" press="handleMasterPress">
<!--<ColumnListItem >-->
<cells>
<ObjectIdentifier title="{mainService>CoNumber}"/>
<ObjectIdentifier text="{mainService>CoNumber}"/>
<ObjectIdentifier text="{mainService>CoNumber}"/>
<ObjectIdentifier text="{mainService>CoNumber}"/>
<ObjectStatus text="{path:'mainService>Status', formatter:'.formatPurposeStatus'}"
state="{path:'mainService>Status', formatter:'.formatStatusColor'}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</Panel>
</mvc:View>
</script>
</head>
<body id='content' class='sapUiBody'>
</body>
</html>
Add the following attribute to the items element within the Table element:
items="{
path: '{mainService>/Bp}',
type : 'sap.m.ListType.Active'
}"
Refer
sap.m.ListType.Active
Indicates that the item is clickable via active feedback when item is pressed.
Source: https://openui5.hana.ondemand.com/#/api/sap.m.ListType/overview

getBindingContext() is undefined

I'm making a little program for a school assignment, but I encounter a problem.
I need to make a program in SAPUI5 that loads JSON data in a table. On each row there is a function (onItemSelected) attached. So when I press on a row, I need to get the ID of the weekday.
This is how the program looks like now:
When I press on a row, it says that my getBindingContext() is undefined.
In my index.html
sap.ui.getCore().attachInit(function(){
var oWeekdagModel = new sap.ui.model.json.JSONModel();
oWeekdagModel.loadData("./model/weekdagen.json");
sap.ui.getCore().setModel(oWeekdagModel, "week");
});
var oResourceModel = new sap.ui.model.resource.ResourceModel({
bundleName : "sap.ui.demo.db.i18n.i18n"
});
sap.ui.getCore().setModel(oResourceModel, "i18n");
new sap.ui.core.mvc.XMLView({
viewName: "sap.ui.demo.db.view.App"
}).placeAt("content");
App.view.xml
<mvc:View
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
controllerName="sap.ui.demo.db.controller.App"
>
<Table id="idWeekdagenTable"
inset="false"
items="{week>/weekdays}"
>
<headerToolbar>
<!-- ... -->
</headerToolbar>
<columns>
<Column width="20%">
<Text text="Id" />
</Column>
<Column width="20%">
<Text text="Weekdag" />
</Column>
<Column width="20%">
<Text text="Aantal gewoon eten" />
</Column>
</columns>
<items>
<ColumnListItem
press=".onItemSelected"
type="Active"
>
<Text id="id" text="{week>id}" />
<Text id="day" text="{week>day}" />
<Text text="{week>no_meals}" />
</ColumnListItem>
</items>
</Table>
<Table id="idMaaltijdenTable"
inset="false"
items="{maaltijd>/meals}"
>
<headerToolbar>
<!-- ... -->
</headerToolbar>
<columns>
<Column width="20%">
<Text text="Maaltijd" />
</Column>
<Column width="20%">
<Text text="Descriptie"/>
</Column>
</columns>
<items>
<ColumnListItem
press=".onItemSelected"
type="Active"
>
<Text text="{maaltijd>MealNo}" />
<Text text="{maaltijd>items}" />
</ColumnListItem>
</items>
</Table>
</mvc:View>
App.controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller){
"use strict";
return Controller.extend("sap.ui.demo.db.controller.App", {
onInit: function() {
var oWeekdagModel = new sap.ui.model.json.JSONModel();
oWeekdagModel.loadData("weekdagen.json");
//binding op view
sap.ui.getCore().setModel(oWeekdagModel);
},
onItemSelected: function(oEvent) {
var oItem, oCtx;
oItem = oEvent.getSource();
oCtx = oItem.getBindingContext();
alert(oCtx); // is undefined
}
});
});
You can pull out the day's ID from the model using binding path. Here is a relevant part of your onItemSelected() function:
...
oCtx = oItem.getBindingContext();
var oPressedItem = sap.ui.getCore().getModel().getProperty(oCtx.getPath());
...
and then oPressedItem.id will give you the ID of the day from the top table and oPressedItem.dayId - from the bottom table.
Here is a working example.

SAPUI5 I can't load the table from the Rest Service

I'm in trouble. I can load my table from the same local Json, however, I can not load a table when I read the Rest. Both are returning the Json because I tested.
Would this error be related to Syncronous and Asyncronous?
This is the code which is not working
var oModelGET = new JSONModel();
var urlGET = 'http://localhost/Compliance/api/RestServiceImpl.svc/getTFCompanyList';
var parametersGET = {};
var headersGET = {
"Accept": "application/json",
"X-Invoiceware-Token": oModelPOST.getProperty("/Token"),
"Content-Type": "application/json"
};
oModelGET.loadData(urlGET, parametersGET, false, "GET", false, "false", headersGET);
this.setModel(oModelGET, "products");
This code is working:
// set invoice model - local
var oInvoiceModel = new JSONModel()
var invoiceLocal = "/test/localService/mockdata/Products.json";
var sNamespace = "sap.ui.compliance";
oInvoiceModel.loadData(jQuery.sap.getModulePath(sNamespace, invoiceLocal));
this.setModel(oInvoiceModel, "products");
This is my xml
<core:View
controllerName="controller.security.Companies"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:core="sap.ui.core"
xmlns="sap.m">
<Page title="{i18n>companiesViewTitle}">
<content>
<Table busyIndicatorDelay="{worklistView>/tableBusyDelay}"
class="sapUiResponsiveMargin"
growing="true"
growingScrollToLoad="true"
id="tableCompanies"
items="{ path: 'products>/Products', sorter: { path: 'products>/Name', descending: false } }"
noDataText="{worklistView>/tableNoDataText}"
updateFinished="onUpdateFinished" width="auto">
<headerToolbar>
<Toolbar>
<Title id="tableCompanyHeader" text="Companies (n)"/>
<ToolbarSpacer/>
<SearchField id="searchField" search="onSearch" tooltip="Search" width="auto"></SearchField>
<Button type="Default" icon="sap-icon://add" press="handleNewCompanypress"/>
</Toolbar>
</headerToolbar>
<columns>
<Column id="companyCol" minScreenWidth="Small" demandPopin="true">
<Text text="Company" />
</Column>
<Column id="nameCol" minScreenWidth="Small" demandPopin="true">
<Text text="Name" />
</Column>
</columns>
<items>
<ColumnListItem press="handleListItempress" type="Navigation">
<cells>
<ObjectIdentifier
title="{products>Name}"/>
<Text
text="{products>SearchCode}" />
</cells>
</ColumnListItem>
</items>
</Table>
</content>
<footer>
<OverflowToolbar id="otbFooter">
</OverflowToolbar>
</footer>
</Page>
</core:View>
Thank you

binding is not working on table for sapui5

I created xml view and controller to bind data.
I don't see any data.
Did I miss something?
<sap.ui.core.mvc:View controllerName="view.weeklyTasks"
xmlns="sap.m"
xmlns:sap.ui.core="sap.ui.core"
xmlns:sap.ui.core.mvc="sap.ui.core.mvc">
<Page title="Title">
<content>
<Table id="idProductsTable" noDataText="No data" items="{path: '/modelData'}" >
<columns>
<Column>
<Text text="Product" />
</Column>
<Column>
<Text text="Supplier" />
</Column>
</columns>
<items>
<ColumnListItem counter="0">
<cells>
<Text text="{name}"></Text>
<Text text="{date}"></Text>
</cells>
</ColumnListItem>
</items>
<headerToolbar>
<Toolbar>
<content>
<Label text="Weekly Tasks"></Label>
</content>
</Toolbar>
</headerToolbar>
</Table>
</content>
</Page>
</sap.ui.core.mvc:View>
sap.ui.controller("view.weeklyTasks", {
onInit: function() {
var aData = { modelData : [
{name: "Peter", date: "01012010"},
{name: "Petra", date: "01012011"},
{name: "Thomas", date: "01012012"},
{name: "John", date: "01012013"},
{name: "Maria", date: "01012014"}
]};
var oModel = new sap.ui.model.json.JSONModel(aData);
this.getView().setModel(oModel);
}
});
Ok now I could make things work.
1 - Add the parameter below to your bootstap
data-sap-ui-xx-bindingSyntax="complex"
More info regarding data-sap-ui-xx-binding Syntax:
Data Modeling for controls using XML views(SAPUI5)
SAP Help - SAPUI5 Configuration Options
2 - Your view is OK
<Page title="Title">
<content>
<Table id="idProductsTable" noDataText="No data" items="{path: '/modelData'}" >
<columns>
<Column>
<Text text="Product" />
</Column>
<Column>
<Text text="Supplier" />
</Column>
</columns>
<items>
<ColumnListItem >
<cells>
<Text text="{name}"></Text>
<Text text="{date}"></Text>
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
3 - Update your controller fixing JSON format
onInit: function() {
var aData = { "modelData" : [
{"name": "Peter", "date": "01012010"},
{"name": "Petra", "date": "01012011"},
{"name": "Thomas", "date": "01012012"},
{"name": "John", "date": "01012013"},
{"name": "Maria", "date": "01012014"}
]};
var oModel = new sap.ui.model.json.JSONModel(aData);
this.getView().setModel(oModel);
// OR sap.ui.getCore().setModel(oModel);
}
I am looking to bind the items property in the controller so it can change dynamically, how would I go about doing this?
I imagine it would be something like oTable.items = "{odataURL}"
My URL current works if hardcoded in, but I am not sure how I could get the same results doing this in the controller.js
As per Question asked there is no need to make change in JSON format .
Normally we use Complex Binding when we have formatter/sorter or path added
we can achieve above result in other way also
just remove **path** from item and remove **data-sap-ui-xx-bindingSyntax="complex"** in index.html
<Table id="idProductsTable" noDataText="No data" items="{/modelData}">
<columns>
<Column>
<Text text="Product" />
</Column>
<Column>
<Text text="Supplier" />
</Column>
</columns>
<items>
<ColumnListItem >
<cells>
<Text text="{name}"></Text>
<Text text="{date}"></Text>
</cells>
</ColumnListItem>
</items>
</Table>