代码之家  ›  专栏  ›  技术社区  ›  Dmitriy Ivanko

@泳道/ngx数据表虚拟滚动仅适用于缓存行

  •  3
  • Dmitriy Ivanko  · 技术社区  · 6 年前

    @swimlane/ngx datatable虚拟滚动仅适用于缓存行。缓存的行保留在数组中。在我的例子中,行的数量可以超过1000万。如何不缓存该行并使用虚拟滚动?

    问题再现:

    http://prntscr.com/kw9q51

    2) 回购: https://github.com/DmitriyIvanko/ngx-datatable-example/blob/master/src/app/app.component.ts

    1 回复  |  直到 6 年前
        1
  •  0
  •   Dmitriy Ivanko    6 年前

    我的黑客解决方案是模拟缓存行: 创建“未定义”数组(长度为100),从第50行开始替换20行;

    const totalRow = 100;
    const skip = 50;
    const take = 20;
    const serverRow = [{...}] // array of row, with length = 20;
    
    const resultList = new Array(totalRow).fill(undefined);
    resultList.splice(skip, serverRow.length, ...serverRow);
    

    我用1000万行检查这个解决方案,它的运行速度非常快; 也许这会帮助别人。

    推荐文章