如何在不需要时隐藏 angular-ui-grid 滚动条?

how to hide angular-ui-grid scrollBar when it's unnecessary?

when I use angular-ui-grid,I found the HorizontalScrollbar always appears. And I try to use enableHorizontalScrollbar:2 in gridOptions. But it doesn't work.and when I show or hide the HorizontalScrollbar like this example.

The left side's selection will be malposition.
any solution?

这是一个尺寸问题,尝试设置列的宽度以适合您的对象尺寸,当您这样做时水平滚动条将消失。

将列大小更改为

   $scope.gridOptions.columnDefs = [
       { name:'id', width:50},
       { name:'name', width:50 },
       { name:'age', width:50 }
     ];

生成没有水平线的table


angular-ui-grid 你有一个 autoResize 选项,这应该可以解决你的问题如果数据实际上可以适合 table.

您可以在这里阅读: http://ui-grid.info/docs/#/tutorial/213_auto_resizing