滚动结束排序后,UI-Grid滚动/分页不起作用

时间:2019-01-04 11:22:41

标签: angular user-interface web frontend angular-ui-grid

在UI-Grid中滚动到列表的末尾后,如果单击可排序的列,则分页a.k.a.无限滚动将不起作用,并且表仅由一组行固定。如果进一步滚动,则UI网格中不会发生分页。看起来当到达最后一行时,无限滚动被禁用了。

我尝试重置网格,但它不支持该问题。

this.gridOptions.onRegisterApi = (gridApi) => {
  gridApi.infiniteScroll.on.needLoadMoreData(this.$scope, () => {
    if (this.Events.page < this.Events.totalPages) {
      this.Events.page++;
      this.gridApi.infiniteScroll.saveScrollPercentage();
      return this.gridApi.infiniteScroll.dataLoaded(false, true);
    }
  });
  this.gridApi = gridApi;
  this.getColumnSettings();
  this.gridApi.core.on.sortChanged(this.$scope, (grid, sortColumns) => {
      this.sortChanged(grid, sortColumns);
  });
};

我在排序更改时调用此函数。也就是说,如果点击了列标题,

public sortChanged(grid, sortColumns) {
  this.isSortEnabled = true;
  this.sortState.fieldName = "";
  this.Events = new EventsPage();
  this.gridSpinner = true;
  this.gridOptions.data = [];
  this.gridApi.infiniteScroll.dataLoaded();
  this.gridApi.infiniteScroll.resetScroll(false, false);
  if (sortColumns.length > 0) {
      this.setFieldName(sortColumns[0].field);
      if (sortColumns[0].sort.direction === "desc") {
          this.sortState.fieldName = "-" + this.sortState.fieldName;
      }
  }
  else {
    this.sortState.fieldName = "someSortParameter";
  }
  this.getEvents();
}

应该出现分页,并在到达列表末尾然后单击列标题上的sort后调用gridApi.infiniteScroll.on.needLoadMoreData()。

0 个答案:

没有答案