Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table: Dont show error for missing nested keys #1173

Closed
MickL opened this issue Dec 29, 2023 · 2 comments
Closed

Table: Dont show error for missing nested keys #1173

MickL opened this issue Dec 29, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@MickL
Copy link

MickL commented Dec 29, 2023

Description

I have data with optional nested objects:

const data = [
  {
    name: 'Max',
    profile: {
       age: 12,
    }
  },
  {
    name: 'John',
  },
]

Which I display in a table:

const tableColumns = [
  {
    key: 'name',
    label: 'Name',
  },
  {
    key: 'profile.age',
    label: 'Age',
  },
];

Now the second row shows an error in the age column:

Failed to get cell value

Which is correct, but instead I would like to display nothing or a "-"

Additional context

No response

@MickL MickL added the enhancement New feature or request label Dec 29, 2023
@MickL
Copy link
Author

MickL commented Jan 2, 2024

@benjamincanac Wouldnt it make sense to be able to customize the output? :)

Copy link
Member

You can already customize it by using the slot, you get passed the getRowData where you can pass a defaultValue: https://github.com/nuxt/ui/blob/dev/src/runtime/components/data/Table.vue#L58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants