Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

[DataTable] accept nested objects in "rows" array #498

Open
sillybutt0 opened this issue Aug 30, 2017 · 1 comment
Open

[DataTable] accept nested objects in "rows" array #498

sillybutt0 opened this issue Aug 30, 2017 · 1 comment

Comments

@sillybutt0
Copy link

Currently we need to connect data in "rows" prop of DataTable component with TableHeader's "name" prop to work properly. But having nested object in "rows" array will not connect them and sort.

Example of how now works:

const data = [{email: 'test@test.com', name: 'Alex'}];

<DataTable rows={data}>
  <TableHeader name="email">Email</TableHeader>
  <TableHeader name="name">Name</TableHeader>
</DataTable>

And how does not work:

const data = [{email: 'test@test.com', profile: { name: 'Alex' }}];

<DataTable rows={data}>
  <TableHeader name="email">Email</TableHeader>
  <TableHeader name="name">Name</TableHeader>
</DataTable>

I suggest to type object keys like "profile.name" and make if work correctly with further sorting.

@vegansk
Copy link

vegansk commented Aug 30, 2017

You can use workaround:

<TableHeader name="profile" cellFormatter={(profile) => profile.name}>Name</TableHeader>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants