Git Product home page Git Product logo

Comments (14)

anil1712 avatar anil1712 commented on May 18, 2024 3

Yeah its great solution but I needed header info also. Is there any solution for the same?

from react-data-grid.

Gtosta96 avatar Gtosta96 commented on May 18, 2024 1

It should be well documented 👍

from react-data-grid.

vellov avatar vellov commented on May 18, 2024 1

Holy crap, I looked for this crap for almost 2 hours. This documentation is the worst i've seen.

from react-data-grid.

Nodios avatar Nodios commented on May 18, 2024 1

Damn! @maiis you just saved me tons of time!

from react-data-grid.

bakesteve avatar bakesteve commented on May 18, 2024

we'll track this under #41 as they will have a common solution.
Generally, we feel that a cell (formatter or editor) should not have access to the row data, but there are cases where you need access to some other props. We'd like to be explicit - but still allow people to provide the access if they need it. The solution above works fine, but we'd like to have a cleaner implementation though. Will update the docs too

from react-data-grid.

maiis avatar maiis commented on May 18, 2024

👍

from react-data-grid.

lmaccherone avatar lmaccherone commented on May 18, 2024

I used this getRowMetaData trick myself. Thanks for posting here. Let me know if you add some other mechanism, but I like the current one.

from react-data-grid.

maxcc0 avatar maxcc0 commented on May 18, 2024

thanks @maiis, Just what i was looking for.

from react-data-grid.

urbinopescada avatar urbinopescada commented on May 18, 2024

I've been 2 hours searching for this!!!

from react-data-grid.

jamesajones avatar jamesajones commented on May 18, 2024

If I use the above column definition what does the static propTypes {} look like?

from react-data-grid.

jamesajones avatar jamesajones commented on May 18, 2024

Where

from react-data-grid.

Gtosta96 avatar Gtosta96 commented on May 18, 2024

Yes, such a pity, since the library is very cool...

from react-data-grid.

usersina avatar usersina commented on May 18, 2024

Having the same issue, couldn't replicate the provided solution using JSX as a formatter because it throws a promise rejected exception.

Instead I'm using a function but I can't view the row data.

let columns = [
    ...
    {
      id: 'status',
      name: 'Status',
      getRowMetaData: (row) => row,
      formatter: (_s, _o, rowObject) => _(renderStatus(rowObject)),
    },
    ...
];
const renderStatus = (rowObject) => {
    console.log(rowObject.getRowMetaData); // Returns the string "row => row"
    return <StatusTest myVar={rowObject} />;
};
"gridjs": "^3.3.0",
"gridjs-react": "^3.2.2",

from react-data-grid.

ps1011 avatar ps1011 commented on May 18, 2024

In case anyone still searching for this, we can access row data with params.row for custom rendering which depends on other row data

const columns=[
{
    headerName: "Duration",
    key: "duration",
    description: "run duration",
    // getRowMetaData: (row) => row,
    sortable: true,
    type: "string",
    valueGetter: (params) => {
      console.log("row dat",params.row); // row data object
      const endDate = params.row.completed_date
        ? moment.utc(params.row.completed_date)
        : moment.utc(new Date());
      const startDate = moment.utc(params.row.created_date);
      var diff = moment.duration(endDate.diff(startDate));
      const duration = [diff.hours(), diff.minutes(), diff.seconds()].join(":");
      return duration + " Hrs";
    },
   valueFormatter: (params)=>{
       console.log("row dat",params.row); // row data object
   }
  },
]

from react-data-grid.

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.