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

Not possible to use a nested property for optionLabel/optionValue/optionInfo in CpsSelect #387

Open
lukasmatta opened this issue May 20, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@lukasmatta
Copy link
Collaborator

Currently, if one wants to use nested property for optionLabel/optionValue/optionInfo it's not possible. Let me illustrate on an example:

We have an array of options of the following type:

interface Option {
  name: string;
  address: {
    city: string;
  };
}

And we want to use it in a CpsSelect:

<cps-select
  [options]="options"
  optionLabel="address.city" <!-- currently not possible -->
>
</cps-select>

I'd suggest supporting not only string type but also a Function type for those inputs, so that a user can define custom function that will take option object and would return value to be used for optionLabel/Value/Info, e.g.:

const getCity = (option: Option): string => option.address.city;
<cps-select
  [options]="options"
  optionLabel="getCity"
>
</cps-select>

Components that might also support this:
CpsSelect/CpsTreeSelect
CpsAutocomplete/CpsTreeAutocomplete

@lukasmatta lukasmatta added the enhancement New feature or request label May 20, 2024
@lukasmatta lukasmatta self-assigned this May 20, 2024
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

1 participant