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

Support getting nested values with dot notation for UTable columns #363

Closed
BayBreezy opened this issue Jun 28, 2023 · 3 comments · Fixed by #503
Closed

Support getting nested values with dot notation for UTable columns #363

BayBreezy opened this issue Jun 28, 2023 · 3 comments · Fixed by #503
Labels
enhancement New feature or request

Comments

@BayBreezy
Copy link

When a nested object is returned from the API, it would be nice if the configured columns key property could be set to get that value that is nested. So if my api returned an object like this:

[{
  name: "John",
  mother: {
    name: "Sally",
    sister: {
      name: "Shelly"
    }
  }
}]

We should be able to pass the key like this to the columns prop:

const columns = [
  { label: "Aunt", key: "mother.sister.name" }
];

This can be achieved with the get function from lodash --> https://lodash.com/docs/4.17.15#get
So maybe instead of doing this {{ row[column.key] }}, we could try this {{ row[get(rows, column.key, row[column.key])] }}

@BayBreezy BayBreezy added the enhancement New feature or request label Jun 28, 2023
@goodpixels
Copy link

goodpixels commented Jun 29, 2023

I can only express my personal opinion as a user of this library, and perhaps the authors will have a different view, but considering this is meant to be a lean UI kit, I'd think introduction of third party scripts should be kept to minimum.

What you've described can be easily achieved as you've demonstrated in the example provided, and I don't think that this use case warrants to have this functionality available out of the box.

In fact, the user has full control over the structure of the object passed to the component as props, and as such the label can be easily derived from a computed property.

@BayBreezy
Copy link
Author

Hey @goodpixels ,
I understand your point. The thing is, lodash is already being used in the table component lol
I agree with you on not adding too many external libraries, which is why I didn't even bother mention a validation library for the input elements

Copy link
Member

It is indeed the philosophy of the module not to rely on external libraries but I don't mind using lodash. Those functions are really small and already used in some components.

Would you mind opening a PR?

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

Successfully merging a pull request may close this issue.

3 participants