AbsaOSS / AbsaOSS/cps-shared-ui

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

Offen
#387 0 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @lukasmatta Auf GitHub ansehen
enhancement
Vorherrschende Sprache
TypeScript
Sterne
9
Forks
6
Ø Merge
23 Std. 46 Min.
Gemergte PRs (30 T.)
5

Beschreibung

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:

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

And we want to use it in a `CpsSelect`:

```html

>

```

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.:

```js
const getCity = (option: Option): string => option.address.city;
```

```html

```

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.