小编Dan*_*Dan的帖子

Ag-Grid 重置新数据源上的滚动

我在 Ag-Grid 相关代码之外更新数据。我有一个变量 ,this.works它存储我的投资组合管理器项目的所有用户“投资组合”。我this.loadMore()从服务器加载了更多数据(我无权访问,这就是我从外部加载数据的原因)。

我正在采用“无限”行模型来实现无限滚动。我开始使用数据源是因为我也想使用排序和过滤。

问题是,当我更新数据源时,滚动会重置到顶部。这是非常烦人的行为。

使用 Ag-Grid 社区和 Vue.js。

GridOptions(在 beforeMount() 中设置)

  this.gridOptions = {
    suppressScrollOnNewData: true,
    rowSelection: 'single',
    rowModelType: 'infinite',
    deltaRowDataMode: true,
    defaultColDef: {
      sortable: false,
      resizable: true
    },
    columnTypes: {
      'imageColumn': {
        width: 150,
        sortable: false,
        autoHeight: true,
        cellRendererFramework: AgGridImageFormatter
      },
      'priceColumn': {
        cellRendererFramework: AgGridPriceFormatter
      }
    }
  };
Run Code Online (Sandbox Code Playgroud)

方法:

({
  methods: {
    onBodyScroll: function(event) {
      var lastDisplayedWork, ref, worksCount;
      worksCount = this.works.length;
      lastDisplayedWork = (ref = this.gridOptions.api) != null ? ref.getLastDisplayedRow() : void …
Run Code Online (Sandbox Code Playgroud)

javascript coffeescript vue.js ag-grid ag-grid-vue

5
推荐指数
1
解决办法
4168
查看次数

标签 统计

ag-grid ×1

ag-grid-vue ×1

coffeescript ×1

javascript ×1

vue.js ×1