OnDemandGrid(Dgrid)不会触发请求

问题描述 投票:0回答:1

滚动网格时,当您到达20个项目的末尾时,它不会触发更多项目的新请求

我正在使用Dojo版本1.10.4。我创建了一个TrackableRest商店

    var TrackableRest = declare([Rest, Trackable]);
    var interceptStore = new TrackableRest({
        target: 'rest/intercepts/', 
        accepts: "application/json",
        sortParam: 'sort',         
        rangeStartParam: 'offset',
        rangeCountParam: 'limit',
        headers:{
            'Accept': "application/json",
            'Content-Type':"application/json",
            'charset':"UTF-8"             
        },
        idProperty: 'id'
    });

然后我创建了一个网格:

var grid = window.grid = new CustomGrid({
    id: 'grid',
    //sort: [{property:'ELNOT'},{property:'RF_AVG'}], // Initialize sort on last name, ascending
    collection: interceptsStore,
    sort: "id",
    getBeforePut: false,
    columns: getColumns(),
    allowSelectAll: true,
    loadingMessage: 'Loading data...',
    noDataMessage: 'No results found.',
    title: "All",
    minRowsPerPage: 20,
    maxRowsPerPage: 250
});

请求发送http://localhost:8080/OlympiaMap/rest/intercepts/?sort=+id&offset=0&limit=20

并且响应包括标题Content-Range,其值为items = 0-20 / 606,数据看起来像enter image description here

dojo dgrid
1个回答
0
投票

因此,经过两天的等待,我意识到即使您以所需的格式返回内容标题,它似乎也在使用您的响应总计,限制和偏移量中的值(或者您为开始和计数参数选择的任何值)。例如,在我的响应标题中,我返回Content-Range,其值为“items 0-20 / 606”,但在实际响应中,我有一个包含20个项目且总共20个的items数组。当我对此值进行硬编码时(只是为了测试)匹配606值我开始看到虚拟滚动工作并发送请求增加开始和计数。喜欢这个第1页加载http://localhost:8080/OlympiaMap/rest/intercepts/?sort=+id&offset=0&limit=20

滚动http://localhost:8080/OlympiaMap/rest/intercepts/?sort=+id&offset=20&limit=20

等等

这是因为缺少dstore和dgrid的部分文档

© www.soinside.com 2019 - 2024. All rights reserved.