react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Easiest way to enable text wrapping?

Open alvaro1728 opened this issue 10 years ago • 12 comments

Hi and once again, thanks for this great component!

I have a row with a "description" column that truncates its text when it overflows. What's the easiest way to allow the row height to expand to accommodate text wrapping?

Thanks, Alvaro

alvaro1728 avatar Mar 13 '16 03:03 alvaro1728

I literally had to figure this out with the help of the contributors.

https://github.com/adazzle/react-data-grid/issues/245

danfernand avatar Mar 13 '16 15:03 danfernand

hey @alvaro1728 -- see @danfernand 's linked issue above if you want to include an ellipses for the text overflow.

if you wanted something more like dynamic height which automatically expands a row, we don't have anything like that currently... You could pass in a custom rowHeight to the grid, but at the moment this will apply to all rows.

do either of those options suit your use case?

jpdriver avatar Mar 14 '16 10:03 jpdriver

Hi @danfernand and @jpdriver, thanks for your replies.

I guess I was looking more for the typical HTML table behavior where if a td has too much text, it automatically wraps it and makes that row taller. However... I came up with a slicker solution, or so I think. :-) I'm wrote some jquery/css code that attaches a mouseenter event to my "description" cells to dynamically expand their height and show the full text.

image

image

Let me know if you're interested in my concoction.

Thanks, Alvaro

alvaro1728 avatar Mar 15 '16 03:03 alvaro1728

nice! any chance you could open a PR for it? think we'd definitely be interested to see :smile:

jpdriver avatar Mar 16 '16 09:03 jpdriver

Will close as it is a duplicated for #102

diogofcunha avatar Jan 25 '17 16:01 diogofcunha

@alvaro1728 How did you calculate the height that you need to expand the row?

strygul avatar Feb 08 '18 15:02 strygul

Any update on this feature ?

sunil-srma avatar Aug 28 '18 05:08 sunil-srma

This library releasing new version on every month like angular, but still not solved dynamic row height related issue which is most used in data table. After spending 2 month in my project, and this issue forcing me to adopting another table library.

rao123dk avatar Dec 06 '18 09:12 rao123dk

@rao123dk Can you please share the library that you used to achieve dynamic row height?

sheshagiri-t avatar Jan 10 '20 05:01 sheshagiri-t

@rao123dk Can you please share the library that you used to achieve dynamic row height?

https://github.com/DevExpress/devextreme-reactive .

rao123dk avatar Jan 10 '20 19:01 rao123dk

I was able to enable text wrapping with a CSS workaround:

this is the result: image

to achieve this, I just:

  • added the property cellClass: css.myClassThatEnablesTextWrapping to each item of the columns
  • and this is the content of the CSS class:
.myClassThatEnablesTextWrapping {
  text-overflow: ellipsis;
  white-space: break-spaces;
  overflow-y: auto;
 // this is another workaround that makes the scroll appears only for cases where it is really necessary
  height: calc(100% + 2%);
}

This solution works for:

  • ✅ editable cells
  • ✅ resizable cells

wesleyramalho avatar Jan 25 '22 22:01 wesleyramalho

.test {
    display: inline-block;
    line-height: 1.5;
    overflow-wrap: break-word;
    white-space: normal;
    text-align: justify;
}

ianmaciel7 avatar May 12 '22 19:05 ianmaciel7