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

Passing a class to prevent text overflow does not work as expected.

Open danfernand opened this issue 10 years ago • 4 comments

If I try to pass a column definition to prevent text overflow like such

const columns = [
...
  {
    key: 'problem',
    name: 'Problem',
    cellClass: 'no-overflow',
  }
...
];

the class is defined like so

.no-overflow {
  text-overflow: ellipsis;
}

The cell does not prevent text from overflowing to the next line

danfernand avatar Mar 11 '16 16:03 danfernand

Was able to, solve with some css, basically you need to target the div that owns the text

.no-overflow .react-grid-Cell__value div {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

It's a lil odd and maybe can be a built in to the column properties, but that would be an enhancement

danfernand avatar Mar 12 '16 15:03 danfernand

Thanks for posting your solution to this, Dan - helped me.

siliconeidolon avatar Sep 21 '17 09:09 siliconeidolon

@danfernand But it is not working for custom components in table cell. Please suggest some workaround..

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

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 23:01 wesleyramalho