【问题标题】:Response Header with a JsonRestStore (with Dgrid/Dojo)带有 JsonRestStore 的响应标头(使用 Dgrid/Dojo)
【发布时间】:2012-07-25 20:12:24
【问题描述】:

尝试使用我的 json 存储构建动态网格,但由于某种原因存在范围限制,我猜它是 dgrid/store 实现的一部分,但我应该向下滚动网格并从 dgrid 的示例中获得更多结果网站。

我会在这里放一些代码。首先,我试图在我的代码中非常模块化,所以我有一个获取我的商店 (content.js) 的文件,一个构建我的网格 (gridlayout.js) 和 main.js 的文件(创建我的实例并传递我的商店)。

content.js

define([
    "dojo/_base/xhr",
    "dojo/store/Memory",
    "dojo/store/JsonRest",
    "dojo/store/Cache"
    ],
function(
    xhr,
    Memory,
    JsonRest,
    Cache
){

    var contentMemoryStore = new Memory();
    var contentJsonRestStore = new JsonRest({target: "http://dev.mpact.tv:30087/rest/contenus/"});

    contentStore = new Cache(contentJsonRestStore, contentMemoryStore);

    return contentStore;
});

GridLayout.js

define([
    "dojo/_base/declare",
    "dijit/_WidgetBase",
    "dgrid/OnDemandGrid",
    "dgrid/Keyboard", 
    "dgrid/Selection",
    "dgrid/extensions/ColumnHider",
    "dgrid/editor",
], function(
    declare,
    _WidgetBase,
    Grid,
    Keyboard, 
    Selection,
    Hider,
    editor
){

    return declare([Grid, Keyboard, Selection, Hider], {

    columns: {
        selected: editor({
                    label: " ",
                    autoSave: true,
                    sortable: false
                }, "checkbox"),
        nom: "Name",
        autodelete: "Auto-delete",
        groupe_id: "Groupe ID",
        global: "Global",
        date: "Date",
        duree: "Lenght",
        description: "Description",
        fichier: "Filename",
        pleinecran: "Fullscreen",
        repertoire: "Folder",
        taille: "Size",
        expiration: "Expired",
        id: "id",
        catergorie: "Category",
        brouillon: "Example"
    },

    });
});

还有我的 ma​​in.js

var gridLayout = new GridLayout({}, "placeholder");
gridLayout.set("store", contentStore);

到目前为止,我只有 25 个结果,如果我向下滚动,我不会得到其余的项目。

【问题讨论】:

  • 服务器端有多少项?

标签: javascript dojo dgrid


【解决方案1】:

浏览器中的答案显示项目 0-24/25。这意味着服务器端的项目总数为 25。因此网格不会尝试获取更多。

如果它返回 0-24/1000,那么当你滚动时会有多个调用。

所以我认为你应该检查服务器端为什么它只返回 25 作为 total 项目数。

检查这个:http://dojotoolkit.org/reference-guide/1.7/dojo/store/JsonRest.html#id7

【讨论】:

  • hmmm .. 不是真正的服务器端,它更多的是关于请求。检查请求头。
  • @fneron 服务器应返回最大项目数 - 检查:dojotoolkit.org/reference-guide/1.7/dojo/store/…
  • ohhhh... 所以,我确实需要将其设置为最大/总计。 dojotoolkit.org/reference-guide/1.7/dojo/store/…
  • 好的,所以修复了响应头,我得到了我的项目总数。但是当我使用 dgrid 向下滚动时不会调用任何渲染新项目?
  • 我在 chrome 中的控制台收到此错误:拒绝获取不安全的标头“Content-Range”
猜你喜欢
  • 2012-12-07
  • 1970-01-01
  • 2015-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-25
相关资源
最近更新 更多