Giter Site home page Giter Site logo

Comments (4)

michelengelen avatar michelengelen commented on July 22, 2024

The demo you provided is not working because the Tooltip will always render, regardless of the overflow state of the cell content.

You have to come up with a way to determine if the content of the cell overflows and render the Tooltip visibility based on that.

For questions like these I would recommend asking the community over at StackOverflow or on our community discord server.

Since this is not a problem with the data grid itself I will close this issue for now.
Thanks for taking the time anyways! ๐Ÿ™‡๐Ÿผ

from mui-x.

github-actions avatar github-actions commented on July 22, 2024

๐Ÿ‘‹ Thanks for using MUI X!

We use GitHub issues as a bug and feature requests tracker, however,
this issue appears to be a support request.

For support, please check out https://mui.com/x/introduction/support/. Thanks!

If you have a question on Stackย Overflow, you are welcome to link to it here, it might help others.
If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

from mui-x.

Aberkati avatar Aberkati commented on July 22, 2024

I've already searched on Stackoverflow but I did not found the solution for my problem.
I think it's a DataGrid feature so that's why I contact you..
thank you

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

I've already searched on Stackoverflow but I did not found the solution for my problem. I think it's a DataGrid feature so that's why I contact you.. thank you

I do understand that this might be misleading ... especially the functionality you are trying to build is hard to do and a problem many devs have tried to solve before you.

you could try with a measuring approach:

renderCell: (params) => {
  const textRef = React.useRef(null);
  const [isTruncated, setIsTruncated] = React.useState(false);

  React.useEffect(() => {
    if (textRef.current && textRef.current.scrollWidth > textRef.current.clientWidth) {
      setIsTruncated(true);
    }
  }, [params.row.firstName]);

  return (
    <div ref={textRef}>
      {isTruncated ? (
        <Tooltip title={params.row.firstName} placement="bottom">
          <p>{params.row.firstName}</p>
        </Tooltip>
      ) : (
        <p>{params.row.firstName}</p>
      )}
    </div>
  );
},

This example is not working, just as a starting point to understand what has to be done to measure the size of an element.

And on another note: measuring is always hard and you have to take into account the lifecycle of react components as well. At the very least it will have a big impact on the performance of the grid.

from mui-x.

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.