table icon indicating copy to clipboard operation
table copied to clipboard

Table data rendering issue

Open sunil-srma opened this issue 9 years ago • 5 comments

React-table version : 6.5.3

I am trying to render table using sample data below

{ "tableData": [{ "a.status": "closed" }, { "a.status": "opened" }, { "a.status": "reopened" }], "columns": [{ "Header": "Activity Status", "accessor": "a.status" }] }

columns are rendering perfectly but data is not rendering. After long struggle when I change my data like this : { "tableData": [{ "a_status": "closed" }, { "a_status": "opened" }, { "a_status": "reopened" }], "columns": [{ "Header": "Activity Status", "accessor": "a_status" }] }

What is the solution, if I want to render with first set of data.

sunil-srma avatar Sep 27 '17 13:09 sunil-srma

I think you will find that . is interpreted to mean object member access.

So a.status requires a data structure like

  {
    a: {
      status: 'closed'
    }
  }

baerrach avatar Sep 28 '17 01:09 baerrach

@baerrach thanks for your reply...

{ "tableData": [{ "a":{"status": "closed" }}, { "a":{"status": "opened" } }, { "a":{"status": "reopened"} }], "columns": [{ "Header": "Activity Status", "accessor": "a.status" }] }

SO it would work ?

sunil-srma avatar Sep 28 '17 04:09 sunil-srma

Did you try it?

baerrach avatar Sep 28 '17 07:09 baerrach

You have not shown us how your columns are configured. react-table supports dot syntax in the accessor (such as accessor: 'a.status') or you can use a function-based accessor (such as accessor: (row)=>row.a.status. Examples of these are all in the docs.

gary-menzel avatar Sep 28 '17 22:09 gary-menzel

This is a question of implementation. We invite you to join the slack channel and ask for help there or on stack overflow. Thanks!

tannerlinsley avatar Oct 01 '17 17:10 tannerlinsley