I have a JSON model, which I build from a Metadata set.
So I created that JSON array and did the following:
var oModel = new JSONModel({
JSONDataSet: oJSONDataArray
});
this._oFragment.setModel(oModel);
In my fragment, I have a table:
<Table id="tableId" items="{ path:'/JSONDataSet' }">
<columns>
<Column>
<Text text="HeaderColumn1"/>
</Column>
<!-- ... -->
</columns>
<ColumnListItem>
<Text text="{Value1}"/>
<!-- ... -->
</ColumnListItem>
</Table>
Now everything works fine on my fragment. In my list, I'll see all that data from my JSON model, but I still receive this weird error in my console:
List Binding is not bound against a list for /JSONDataSet
How can I solve this issue?
List Binding is not bound against a list for ...
The above error occurs only in ODataListBinding.js and is thrown when the module fails to find the entityset name within the service $metadata document or if the resulting multiplicity is not "*"
. source
In your case, the framework assumes that JSONDataSet
is some entity set name defined in the $metadata which obviously cannot be found. In order to prevent framework to search for that in $metadata, you'll need to tell that JSONDataSet
is not from the unnamed default model (ODataModel) but from another model (JSONModel).
Try to give it a name, and assign the name in the binding definitions like this:
const oModel = new JSONModel({
JSONDataSet: /*some data*/
});
this._oFragment.setModel(oModel, "anotherModel");
<Table id="tableId" items="{anotherModel>/JSONDataSet}">
<!-- ... -->
<ColumnListItem>
<Text text="{anotherModel>Value1}"/>
<!-- ... -->
</ColumnListItem>
</Table>
The framework won't try to resolve anotherModel>/JSONDataSet
until that model is registered and set to the fragment. The error will be gone since the framework now knows that it's not initializing ODataListBinding but a client ListBinding.