facebookarchive / fixed-data-table

A React table component designed to allow presenting thousands of rows of data.
http://facebook.github.io/fixed-data-table/
Other
4.3k stars 553 forks source link

Ellipsis for text overflow in table cell? #454

Closed mirko77 closed 8 years ago

mirko77 commented 8 years ago

Hi there,

I was wondering if it is possible to have the table behave like when I set table-layout: fixed; on the table and then text-overflow:ellipsis on the cell, so the text will always be on a single line with ...

I tried to play with the css but no luck...

tkirda commented 8 years ago

Yes it is possible. Wrap your content into div with the class and set style on that class:

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
mirko77 commented 8 years ago

I tried but it does not work, the text is on a single line and trimmed but the overflow is not replaced by the ellipsis.

I also tried on the example here adding long text to a cell and then play with the css but I get the same result, no ellipsis showing

See screenshot

tkirda commented 8 years ago

That's right, I did not include all the details. This should work:

.cell {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    box-sizing: border-box;
    display: block;
    padding: 8px;
    width: 100%;
}

.cell-overflow {
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
<div class="cell">
    <div class="cell-overflow">
        Long content...
    </div>
</div>
mirko77 commented 8 years ago

It does work indeed!

Many thanks

FredericHeem commented 7 years ago

In my use case, overflow:hidden is also needed in the cell-overflow class

alexedev commented 7 years ago

@tkirda Thanks, you just saved my day!

mobimation commented 7 years ago

Now in 2017 useful with fixed-data-table-2 also !

sdhhqb commented 6 years ago

No need to use two div wrappers, just set

table-layout: fixed;
tuanvayn commented 5 years ago

No need to use two div wrappers, just set

table-layout: fixed;

Many thanks btw all of the columns have the same width size. how to make size of the first column is smallest?

tkirda commented 5 years ago

There is width property on the column.

SevenZark commented 3 years ago

If you go this route, you HAVE to manually set a width on every column on every table in your entire app, if you want anything other than forced equal-width columns. This is a nightmare in a large application. I still have not found a solution which preserves one of the biggest advantages html tables give us - intelligent auto-sizing of columns. With this approach you're hobbling that completely.