1

I'm trying Griddle grid component for React. When I pass an array of objects with primitive fields everything works fine

<Griddle results={[{id: 42}]}/> // works

but when there are objects in fields, it shows an empty table

<Griddle results={[{id: {value: 42}}]}/> // doesn't work

I have complex objects in fields and custom components to display them but the table is just empty. How do I make it work?

1
  • 1
    I am having a similar problem too. Commented Sep 29, 2016 at 9:13

1 Answer 1

1

You can work around this limitation of Griddle with customComponent. In your case the code would look the following:

import React from 'react';
import Griddle from 'griddle-react';

const GriddleValueComponent = props => (<div>{props.data.value}</div>);

var MyComponent = (props) => {

    const columnMetadata = [
        {
            "columnName": "id",
            "order": 1,
            "displayName": "The Value",
            "customComponent": GriddleValueComponent
        }
    ];

    return (
        <div className="cssmFsaDataList">
            <Griddle results={[{id: {value: 42}}]} columnMetadata={columnMetadata} columns={["id"]} />
        </div>
    );
}

export default MyComponent;

Which renders as this:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.