Angular ng-grid row height

前端 未结 6 2120
梦谈多话
梦谈多话 2020-12-09 09:29

is there any way to apply the height of the row in ng-grid according to its content. there is one option rowHeight which is changed the height of all row. But I want dynamic

6条回答
  •  Happy的楠姐
    2020-12-09 10:00

    Researching this discovered that in my fix should call anonymous function $scope.resizeViewPort whenever it makes change to ngGrid data or should be called whenever the viewport rows are updated.

    Examples are after angular performs updates to the rows via data from the ng-grid module. I've found these steps useful in my anonymous function for height only:

    $scope.resizeViewPort = function { // and the two steps below
      // retrieve viewPortHeight
      var viewportHeight = $('ngViewPort').height();
      var gridHeight = $('ngGrid').height();
    
      // set the .ngGridStyle or the first parent of my ngViewPort in current scope
      var viewportHeight = $('.ngViewport').height();
      var canvasHeight = $('.ngCanvas').height();
      var gridHeight = $('.ngGrid').height();
    
      alert("vp:" + viewportHeight + " cv:" + canvasHeight + " gh:" + gridHeight);
      var finalHeight = canvasHeight;
      var minHeight = 150;
      var maxHeight = 300;
    
    
      // if the grid height less than 150 set to 150, same for > 300 set to 300
      if (finalHeight < minHeight) {
        finalHeight = minHeight;
      } else if (finalHeight > viewportHeight) {
        finalHeight = maxHeight;
      }
    
      $(".ngViewport").height(finalHeight);
    }
    

提交回复
热议问题