【问题标题】:OnDemandGrid (Dgrid) won't fire a requestOnDemandGrid (Dgrid) 不会触发请求
【发布时间】:2016-09-22 14:28:00
【问题描述】:

滚动网格时,当您到达 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

【问题讨论】:

  • 您使用哪些插件来创建CustomGrid
  • var CustomGrid = declare([OnDemandGrid, Selection, DijitRegistry, Selector, Keyboard, Editor, ColumnHider, ColumnResizer, ColumnReorder]);

标签: dojo dgrid


【解决方案1】:

因此,经过两天的等待,我意识到即使您以所需格式返回内容标题,它似乎也使用了您的响应总数、限制和偏移量中的值(或者您为开始和计数参数选择的任何值)。例如,在我的响应标头中,我返回了值为“items 0-20/606”的 Content-Range,但在实际响应中,我有一个包含 20 个项目和总共 20 个项目的项目数组。当我硬编码这个值时(只是为了测试)以匹配 606 值,我开始看到虚拟滚动工作并发送增加开始和计数的请求。像这样 页面加载第一 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 的文档

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多