dgrid 1.2.1滚动时OnDemandGrid不触发请求

时间:2018-09-05 01:46:23

标签: javascript dgrid dstore

我正在使用dgrid 1.2.1 OnDemandGrid,并尝试使用dstore 1.1.1和1.1.2(Rest,SimpleQuery,Trackable)。看来无论如何,我都无法使虚拟滚动工作。

我的商店定义为:

seStore = new declare([Rest, SimpleQuery, Trackable])({
    target: appUrl + "api/GET_ITEMS",
    idProperty: "SID",
    sortParam: "sort",
    useRangeHeaders: true  
});

由商店定义的是一种排序和过滤方法:

seStore.getSECollection = function (sortFieldName, desc) {
    var sFilter = {};
    if (sArea != "") {
        sFilter.AREA = sArea;
    }
    var coll = seStore.filter(sFilter).sort({ property: sortFieldName, descending: desc });

    return coll;
}

网格:

// Create a Grid instance 
seGrid = new (declare([OnDemandGrid, Selection, DijitRegistry, Selector, Keyboard, Editor, ColumnHider, ColumnResizer, ColumnReorder]))({
    id: "seGrid",
    idProperty: "SID",
    cellNavigation: true,
    columns: seColumns,
    collection: seStore.getSECollection("SID", true),
    region: 'center',
    selectionMode: "multiple",
    keepScrollPosition: true,
    query: { responseType: "json" },
    getBeforePut: false,
    farOffRemoval: Infinity, // larger than total height of data; never remove rows
    minRowsPerPage: 25, // request more data at a time
    maxRowsPerPage: 50,
    pagingMethod: 'throttleDelayed',
    queryRowsOverlap: 0,
    //loadingMessage: "Loading data...",
    noDataMessage: "No results found.",
    showFooter: true
});

后端REST服务响应提供了正确的响应,其中rItems是我的数据库查询中的项目数组,而rTotal是此查询在数据库中的项目总数:

HttpResponseMessage rm = new HttpResponseMessage(HttpStatusCode.OK);
string dgrJsonResults = Newtonsoft.Json.JsonConvert.SerializeObject(rItems, Formatting.None);
rm.Content = new StringContent(dgrJsonResults, System.Text.Encoding.UTF8);
rm.Content.Headers.ContentRange = new ContentRangeHeaderValue((long)start, (long)count, rTotal) { Unit = "items" };

网格最初正确地加载了所请求的前25个项目,但是在此初始请求之后,一旦我向下滚动到底部(项目25),就不会触发获取下一个数据范围的请求。

有人可以帮我指出正确的方向吗?

0 个答案:

没有答案