加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – Angular UI-Grid(新的) – 基于行的动态/自动调整

发布时间:2020-12-17 07:08:46 所属栏目:安全 来源:网络整理
导读:如何根据行数调整角度ui网格( the new one)?奖金问题,最多显示最大高度或最大行数? 解决方法 这是完整的动态UI-Grid实现. 使用分页选项和分组. $scope.gridOptions = {enableFiltering: true,paginationPageSizes: [10,25,50,100,500],paginationPageSize:
如何根据行数调整角度ui网格( the new one)?奖金问题,最多显示最大高度或最大行数?

解决方法

这是完整的动态UI-Grid实现.

使用分页选项和分组.

$scope.gridOptions = {
enableFiltering: true,paginationPageSizes: [10,25,50,100,500],paginationPageSize: 10,onRegisterApi: function(gridApi) {
  $scope.gridApi = gridApi;
  $scope.gridApi.grid.registerRowsProcessor($scope.singleFilter,200);
  $scope.gridApi.treeBase.on.rowExpanded(null,function(row) {
    updatePagination(row.treeNode.children.length);
  });
  $scope.gridApi.treeBase.on.rowCollapsed(null,function(row) {
    updatePagination(-row.treeNode.children.length);
  });
}

};

功能:

function updatePagination(rowsDifference) {
  //updating pagination will trigger singleFilter where the height is being reset
  $scope.gridOptions.paginationPageSizes = [$scope.gridOptions.paginationPageSize + rowsDifference,500];
  $scope.gridOptions.paginationPageSize = $scope.gridOptions.paginationPageSize + rowsDifference;
}
//you can name the function anything,I was doing global external filtering inside this,so just named this.
$scope.singleFilter = function(renderableRows) {
    $timeout(function() {
      var newHeight = ($scope.gridApi.grid.getVisibleRowCount() * 30) + 145;
      angular.element(document.getElementsByClassName('grid')[0]).css('height',newHeight + 'px');
    },10);
    return renderableRows;
  }

不要忘记注入’ui.grid.grouping’,’ui.grid.autoResize’,’ui.grid.pagination’依赖项

HTML

<div ui-grid="gridOptions" class="grid" ui-grid-auto-resize ui-grid-pagination ui-grid-grouping></div>

Working PLUNKER

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读