Skip to content

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

@lukasmatta

Description

@lukasmatta

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions