Giter VIP home page Giter VIP logo

Comments (6)

gschwa avatar gschwa commented on July 4, 2024 4

For anyone who runs into this same issue, I was able to wrap the table in a CellMeasurer from react-virtualized which made this seamless.

from fixed-data-table-2.

KamranAsif avatar KamranAsif commented on July 4, 2024

The most efficient way is to use some heuristic to estimate your given height. In practice, this is hard to nail down. In our application, we ended up allowing users to resize rows and added a text overlay indicating that there was content that was hidden.

You could use some magic in componentDidMount to calculate desired row height and use that. Heres a quick example where rowHeight are generated dynamically: https://jsfiddle.net/c39qj6nd/

I would definitely not recommend if you are worried about performance

from fixed-data-table-2.

SoaresMG avatar SoaresMG commented on July 4, 2024

@gschwa, are you willing to share some code on how you change the cell's height? Just a simple example.
Thank you.

from fixed-data-table-2.

ditkachuk avatar ditkachuk commented on July 4, 2024

@LESARQ you can write your own cell measurer with componentDidUpdate and use calc results in Table rowHeightGetter

from fixed-data-table-2.

tsnevillecom avatar tsnevillecom commented on July 4, 2024
findLongestValue(arr) {
    var lgth = 0;
    var longestValue;

    for (var i = 0; i < arr.length; i++) {
      if (arr[i] && arr[i].length > lgth) {
        var lgth = arr[i].length;
        longestValue = arr[i];
      }
    }

    return longestValue;
}

getDimensions(txt) {
    this.e = document.createElement("span");
    this.e.style.fontSize = "12px";
    this.e.style.fontFamily = "Signika";
    this.e.style.minWidth = "180px";
    this.e.style.maxWidth = "400px";
    this.e.style.display = "inline-block";
    this.e.style.lineHeight = "1.4";
    this.e.style.padding = "8px";
    this.e.innerHTML = txt;
    document.body.appendChild(this.e);
    var w = this.e.offsetWidth;
    var h = this.e.offsetHeight;
    document.body.removeChild(this.e);
    return { w, h };
  }

I use this combination to get my column widths and row heights. Then you can set a Math.max in your rowHeightGetter to either display the minimum height or the height of the content.

from fixed-data-table-2.

SoaresMG avatar SoaresMG commented on July 4, 2024

Hey, @tsnevillecom I just ended doing my own table component as simple as I could.

Since I don't need table virtualization in my application, it would be an overkill to use this component.

from fixed-data-table-2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.