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.....
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 {...} ...
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); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With