2016-09-22 113 views
0

当滚动发车,它不会激发更多的项目一个新的请求。我创建了一个TrackableRest商店OnDemandGrid(Dgrid)将不会触发请求

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-范围与项目值= 0-20/606 且数据看起来像 enter image description here

+0

的插件做你用来创建'CustomGrid'? –

+0

var CustomGrid = declare([OnDemandGrid,Selection,DijitRegistry,Selector,Keyboard,Editor,ColumnHider,ColumnResizer,ColumnReorder]); –

回答

0

因此,在等待两天后,我意识到即使您以所需的格式返回内容标题,它似乎也会使用响应总数,限制和偏移量中的值(或者您为开始和计数参数选择的值)。例如,在我的响应标题中,我返回的Content-Range的值为“items 0-20/606”,但在实际响应中,我有一个包含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