列表绑定未绑定到/JSONDataSet 的列表 [英] List Binding is not bound against a list for /JSONDataSet

查看:42
本文介绍了列表绑定未绑定到/JSONDataSet 的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 JSON 模型,它是从元数据集构建的.

I have a JSON model, which I build from a Metadata set.

所以我创建了那个 JSON 数组并执行了以下操作:

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>

现在我的片段一切正常.在我的列表中,我将看到来自我的 JSON 模型的所有数据,但我仍然在控制台中收到这个奇怪的错误:

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:

列表绑定未绑定到/JSONDataSet 的列表

List Binding is not bound against a list for /JSONDataSet

我该如何解决这个问题?

How can I solve this issue?

推荐答案

List Binding 没有绑定到一个列表中......

List Binding is not bound against a list for ...

以上错误仅发生在 ODataListBinding.js 中,当模块在服务 $metadata 文档中找不到实体集名称时抛出由此产生的多重性不是 "*".来源

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

在您的情况下,框架假定 JSONDataSet 是在 $metadata 中定义的某个实体集名称,显然无法找到.为了防止框架在 $metadata 中搜索它,您需要告诉 JSONDataSet 不是 来自未命名的默认模型 (ODataModel) 而是来自另一个模型 (JSON 模型).

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>

框架不会尝试解析 anotherModel>/JSONDataSet 直到该模型被注册并设置为片段.该错误将消失,因为框架现在知道它不是初始化 ODataListBinding 而是客户端 ListBinding.

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.

这篇关于列表绑定未绑定到/JSONDataSet 的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆