如何使用 Dojo 的 ItemFileReadStore 中项目以外的数据对象?

发布于 2024-10-02 09:51:13 字数 527 浏览 0 评论 0原文

我正在学习如何使用 Dojo 来使用 Web 服务。以下 JSON 是从 Web 服务返回的。我想通过 ItemFileReadStore 来处理它,但从我到目前为止的尝试来看,ItemFileReadStore 仅在 keywordsstat 术语更改为 items 时才有效。有没有办法告诉 ItemFileReadStore 使用 keywordsstat,或者它必须是项目?似乎另一种选择是编写一个自定义存储,但当 ItemFileReadStore 如此接近时,这似乎有点矫枉过正。

{
  "keywordstat": [{
      "word": "Apple",
      "count": "1"
    }, "word": "It's", "count": "1"
  },
  {
    "word": "The",
    "count": "3"
  },
  {
    "word": "We've",
    "count": "1"
  },
  {
    "word": "amazing",
    "count": "1"
  }]
}

I am learning how to work with webservices using Dojo. The following JSON is returned from a webservice. I would like to handle it via an ItemFileReadStore, but from what I have tried so far the ItemFileReadStore only works if the keywordstat term is changed to items. Is there a way to tell ItemFileReadStore to work with keywordstat, or does it have to be items? It seems the other alternative is to write a custom store but that seems like overkill when ItemFileReadStore is so close.

{
  "keywordstat": [{
      "word": "Apple",
      "count": "1"
    }, "word": "It's", "count": "1"
  },
  {
    "word": "The",
    "count": "3"
  },
  {
    "word": "We've",
    "count": "1"
  },
  {
    "word": "amazing",
    "count": "1"
  }]
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

场罚期间 2024-10-09 09:51:13

事实证明,创建一个新的 ReadStore 非常简单。 问题已解决来创建 KeywordStatReadStore

    this._arrayOfTopLevelItems = dataObject.items;

我通过复制现有的 ItemFileReadStore 并更改为

    this._arrayOfTopLevelItems = dataObject.keywordstat;

Turns out its absurdly simple to make a new ReadStore. I created a KeywordStatReadStore by copying the existing ItemFileReadStore and changing

    this._arrayOfTopLevelItems = dataObject.items;

to

    this._arrayOfTopLevelItems = dataObject.keywordstat;

Problem solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文