0

这是我的代码:

        <script>
require(["dojox/grid/DataGrid", "dojo/store/Memory","dojo/data/ObjectStore", "dojo/store/JsonRest", "dojo/_base/xhr", "dojo/domReady!"], 
        function(DataGrid, Memory, ObjectStore, JsonRest, xhr){

    var gridSimple,
        store,
        dataStore;

    function createGrid(){

        gridSimple = new DataGrid({
            store: dataStore,
            structure: [
                { name: "Name", field: "name", width: "84px" },
                { name: "Last name", field: "lastName", width: "84px" },
                { name: "e-mail", field: "email", width: "120px" }
            ],
            rowsPerPage: 20,
            autoHeight:15,
            selectionMode: "single"     
        }, "grid");

        gridSimple.startup();
    }

    function init(){
        store = new JsonRest({target:  "/users/"});
        dataStore = ObjectStore({objectStore: store});  
        createGrid();
    }

    init();
});
</script>               

    <div id="grid">

    </div>

我正在获取第一页(正在发送 Range 标头),但是当向下滚动时没有任何反应,dojo 没有发送下一个请求。不知道我做错了什么。

我在 Firefox 14.0.1 上,顺便说一句,使用鼠标滚轮滚动真的很慢。我也试过 chrome,没有得到下一页,但至少鼠标滚轮工作得很好。

道场版本:1.7.2

4

1 回答 1

2

问题是我必须在我的回复中添加下一个标题:

response.addHeader("Content-Range", "items " + from + "-" + to + "/" + total);

我不知道这个。这就是他们所说的“REST Paging 标准”。http://dojotoolkit.org/reference-guide/1.7/dojo/store/JsonRest.html#id7

另一方面,Firefox 的滚动速度非常缓慢。不会在 chrome 中发生。

这是错误报告:

http://bugs.dojotoolkit.org/ticket/15487

因此,在 Firefox 首选项>高级>中取消选中“使用平滑​​滚动”。

于 2012-08-14T21:57:19.383 回答