ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Multiline cell in ng-grid 2.0.7 / angularjs nggrid

Open geethaar09 opened this issue 11 years ago • 4 comments

I'm trying to show data in multiple lines in one of the cells, is this possible with ng-grid?

I have a column called ' Related' which is initially empty when the grid loads. Users can select a row and add new relations which shows in the Related column. I want the column to expand to show relations upto 6 relations and then it should go to the next line when the 7th relation is added, like shown in the html table example below.

untitled

Has anyone tried anything similar? My auto width is also not working at this point

geethaar09 avatar May 18 '15 20:05 geethaar09

Two parts to it:

  1. Set the rowHeight to a larger value. Note that all rows have to have the same height, so you need to decide how many lines you want and set the rowHeight appropriately. You cannot have dynamic row heights per row.
  2. Set the cellTemplate so that it supports multiline. In my application I'm using:
<div class="ngCellText" ng-class="col.colIndex()"><span ng-cell-text style="white-space: normal;" translate="{{COL_FIELD}}" translate-values="{param_1: row.entity.param_1, param_2: row.entity.param_2, param_3: row.entity.param_3, param_4: row.entity.param_4}"></span></div>

Your mileage may vary on that, it's been a while since I did it and I think it's a little flaky.

PaulL1 avatar May 18 '15 20:05 PaulL1

I've tried setting the rowHeight to 200px and when the grid renders it sets the row height to 200px which is a lot of empty space. And it looks like there is no way to set dynamic rowheight :(

Also, My Related column gets cut off and it seems like I cannot achieve what I need.

Thanks Paul! capture

geethaar09 avatar May 18 '15 21:05 geethaar09

You have to set the cellTemplate on the related column to allow wrapping, something like the cellTemplate I showed above.

PaulL1 avatar May 18 '15 21:05 PaulL1

Dynamic row heights are not possible due to virtualization. Non-dynamic but custom row heights are being covered in this issue, mostly: #2759. Closing this as a duplicate of that.

c0bra avatar Jun 19 '15 18:06 c0bra