Skip to content

Allow alternate key for DataTable id #5898

Description

@lindseywild

The key for <TableRow> and it’s associated children is generated based off of the id of the passed in data. It would be helpful to be able to customize the key that is used for id since id may not always exist in the data. For instance, I have a private _uid field that I’d prefer to generate the key off of. In my case, the user has access to update the id field so this may results in duplicate keys if they choose the same id.

Example data:

const sampleData = [
    {id: 1, name: 'Sabine', cuisine: 'Italian', location: 'New York', rating: 4.5, _uid: 'abc123'},
    {id: 2, name: 'The Matador', cuisine: 'Mexican', location: 'Los Angeles', rating: 4.0, _uid: 'abc12334'},
    {id: 3, name: 'Nagoya Steakhouse', cuisine: 'Japanese', location: 'San Francisco', rating: 4.2, _uid: 'abc1234'},
  ]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions