在 Angular UI ng-grid 中关闭滚动? [英] Turnoff Scrolling within Angular UI ng-grid?

查看:28
本文介绍了在 Angular UI ng-grid 中关闭滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想使用 Angular UI ng-grid,但似乎找不到告诉网格内的视口不要将溢出设置为自动而不是滚动的选项.

我们想要做的是让表格/网格高度根据网格中行数的大小动态变化.我们有一个固定的最大行数,因此不必担心 DOM 中有太多行.

对去哪里有什么建议吗?

解决方案

我最近遇到了同样的问题,并在 https://groups.google.com/forum/#!topic/angular/KiBXP3eKCDY

您希望 ng-grid 在获得数据后进行初始化.

以下解决方案需要使用angular-ui:

$scope.getTableStyle= function() {var rowHeight=30;var headerHeight=45;返回 {高度:($scope.dataForGrid.length * rowHeight + headerHeight) + "px"};};

We would like to use the Angular UI ng-grid, but can't seem to find an option to tell the viewport within the grid to not set the overflow to auto and not scroll.

What we'd like to do is have the table/grid height be dynamic based off the size of the number of rows in our grid. We have a fixed max number of rows so there is little concern with having too many rows in the DOM.

Any suggestions on where to go?

解决方案

I recently ran into same issues and found a solution at https://groups.google.com/forum/#!topic/angular/KiBXP3eKCDY

You want ng-grid to initialize after you have data.

The following solution requires using angular-ui:

<div ui-if="dataForGrid.length>0" ng-grid="gridOptions" ng-style="getTableStyle()"  />

$scope.getTableStyle= function() {
   var rowHeight=30;
   var headerHeight=45;
   return {
      height: ($scope.dataForGrid.length * rowHeight + headerHeight) + "px"
   };
};

这篇关于在 Angular UI ng-grid 中关闭滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆