ix
ix copied to clipboard
Select component datakey for comparisons
What happened?
The select component seems to compare objects by reference, which is a problem if the value in the form control does not come from the collection that supplies the select. Other frameworks like Prime NG offer a "dataKey" property in order to prevent a deep compare, which enables the user to define the key used in such comparisons.
Due to this, the select field does not show an initial value if the form value came from a different backend call. Performing a mapping for every form control value that is used in a select is an overhead and can require additional refactoring in large existing applications. I solved it by wrapping the select component in another ControlValueAccessor, which handles the mapping.
What type of frontend frameware are you seeing the problem on?
Angular
Which version of iX do you use?
2.0.1
Code to produce this issue.
// product contains an object which is deep compared equal to one of the marketProducts, but has a different reference
<ix-select formControlName="product">
<ix-select-item *ngFor="let item of marketProducts" label="{{ item.name }}" [value]="item">
</ix-select-item>
</ix-select>
Sounds valid can you please provide a link to the mantioned prime ng component which has this dataKey? Or your value accessor ?
https://primeng.org/dropdown https://primeng.org/table
Those two components have the dataKey property.
Internal ref [IX-891]
See answer, regarding on value comparison here: https://github.com/siemens/ix/issues/1270#issuecomment-2151696893