React-data-grid: Document how to pass row data into formatter

Created on 31 Jul 2015  路  12Comments  路  Source: adazzle/react-data-grid

I had a case where I needed to access others row values inside a cell formatter. Maybe be worth documenting it ?

This is how I achieved it.

let columns = [
    ...
    {
        key: 'mykey',
        name: 'My Column',
        formatter: Formatters.myFormatter,
        getRowMetaData: (row) => row
    }
    ...
];

In into my formatter I can access all the row values into this.props.dependentValues

Most helpful comment

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

All 12 comments

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

:+1:

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.

thanks @maiis, Just what i was looking for.

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

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

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

It should be well documented :+1:

Where

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

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

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

Was this page helpful?
0 / 5 - 0 ratings