3

我已经使用 ui-grid 一段时间了。最近我遇到了一个网格问题,如果我传递了一组稍大的数据(比如 50 行),网格不会全部显示。

当我调试并查找我的 $scope.gridOption.data 对象时,它似乎包含所有元素,但仍然只显示少数(大约 10 个)元素。

当我尝试通过单击标题进行排序时,会出现更多行。(有时1或2个)

这是不规则的,也没有模式。它对于不同的数据集随机发生。

我正在使用ui-grid - v3.2.6,并且我有一个带有 a和其他内容div的网格表。我在具有类似实现的页面上有多个这样的网格,但这个问题目前似乎出现在某个网格上。max-heightscroll

我可以起草一个 plunker,但它并没有真正的帮助,因为这个问题是随机的,而且我有一个基本的 ui-grid 实现。

我关注了这个链接https://github.com/angular-ui/ui-grid/issues/424,但是我无法理解它,我仍然被卡住了。

似乎这是一个已知且未修复的错误。但是有什么可行的解决方案吗???

任何帮助表示赞赏..

4

3 回答 3

6

您可以将此 $scope.gridOptions.excessRows 设置为您想要显示的行数,默认情况下,此值在 ui-grid 中设置为 4。

于 2016-10-12T21:45:41.657 回答
5

我遇到了同样的问题,如果在我的情况下行数大于 45,就会发生这种情况。发现设置 self.gridOptions.virtualizationThreshold = data.length + 1; on gridOptions 解决了我的问题。VirtualizationThreshold 必须大于或等于行数。

归功于https://github.com/angular-ui/ui-grid/issues/860

于 2017-02-10T10:06:22.833 回答
0

将 virtualizationThreshold 设置为 data 中的行数 + 1 将起作用,但如果有很多行,则会出现性能问题。

我没有更改虚拟化阈值,而是设置了 rowHeight 和 minRowsToShow。仅供参考:在我的情况下,虚拟化阈值的默认值为 20。

以下设置对我有用:

        $scope.gridOptions = {
            rowHeight: 20, // set this as number and NOT string
                           // even though the documentation says so.
                           // If its set as string, the issue of 
                           // all the rows not getting displayed will appear.
            minRowsToShow: 18, // this sets the height of the grid 
            ...

minRowsToShow 调整网格的高度。rowHeight 也是必需的。如果没有设置 rowHeight,我又遇到了这个问题。也许虚拟化算法需要rowHeight和minRowsToShow。

链接到 ui 网格选项的文档:http://ui-grid.info/docs/#!/api/ui.grid.class: GridOptions

于 2020-03-19T15:16:25.650 回答