Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ng-grid row height

Tags:

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 row height according to its content.

Following is the Plunker I have made, in this I have used cellTemplate to insert Education field, But I want to increase the row height according to education field detail.

http://plnkr.co/edit/tQJNpB?p=preview

According to this link it is not possible: [1]https://github.com/angular-ui/ng-grid/issues/157

But if anyone find the solution.....

like image 314
Poonam Gokani Avatar asked Sep 30 '13 12:09

Poonam Gokani


2 Answers

These classes will make the table act as actual table, using display table-row and table-cell.

.ngCell  {   display : table-cell;   height: auto !important;   overflow:visible;   position: static; }  .ngRow {   display : table-row;   height: auto !important;   position: static; }  .ngCellText{   height: auto !important;   white-space: normal;   overflow:visible; } 

Please note that this is supported by IE8 and up. It's also overriding the entire ng grid classes so it will be wise to use on a "need to" base:

#myTableId .ngCell {...} #myTableId .ngRow {...} ... 
like image 192
Yair Tavor Avatar answered Sep 20 '22 19:09

Yair Tavor


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); } 
like image 29
user3250966 Avatar answered Sep 19 '22 19:09

user3250966