Angularjs ui-grid row not resizing according to content

此生再无相见时 提交于 2019-12-23 04:33:50

问题


I have a ui-grid(v3.0.0-rc.20-8199eb5) cellTemplate which iterates over an array and prints out the names in the column.

{name:'roles', cellTemplate: '<div ng-repeat="role in row.entity.roles>{{role.name}}</div>'}

The row height is not big enough for the content and cuts it off. Row height will differ per entry depending on the amount of roles for the entry.

Is there a way for the entire row to auto expand/resize according to the content in the row?


回答1:


The solution that worked for me in the end was editing the css for the ui-grid.

.ui-grid-cell { display : table-cell; height: auto !important; overflow:visible; position: static; padding-top: 10px; } 
.ui-grid-row { display : table-row; height: auto !important; position: static; } 
.ui-grid-cell-contents{ height: auto !important; white-space: normal; overflow:visible; } 



回答2:


This is my modified CSS in order to get auto row/cell heights. (I modified what @Rentius2407 did slightly and removed some unneccesary(?) properties.

.ui-grid-row {
  display: table-row;
  height: auto !important;
}
.ui-grid-cell {
  display: table-cell;
  height: auto !important;
  vertical-align: middle;
  float: none;
}
.ui-grid-cell-contents {
  height: auto !important;
}

Also, this breaks the virtualization scrolling in ui-grid, so in order to make scrolling work properly, I had to disable virtualization by setting virtualizationThreshold: 100. For my purposes, I know I'll never be displaying more than 100 rows at a time, but you should be able to modify the virtualizationThreshold as necessary.



来源:https://stackoverflow.com/questions/29648643/angularjs-ui-grid-row-not-resizing-according-to-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!