Warm tip: This article is reproduced from serverfault.com, please click

Smart fields that are rendered as drop down does not show description

发布于 2020-08-12 09:56:16

I have a smart field that I defined like this:

<smartField:SmartField value="{MarktID}" textInEditModeSource="ValueList" >
    <smartField:configuration>
        <smartField:Configuration preventInitialDataFetchInValueHelpDialog="false" displayBehaviour="idAndDescription"/>
    </smartField:configuration>
</smartField:SmartField>

it's rendered like this (i.e. as drop down or select):

enter image description here

because I have this definition in my annotation file:

<Annotations Target="Metadata.Meldungen/MarktID">
    <Annotation Term="Common.ValueListWithFixedValues" Bool="true"/>
    <Annotation Term="Common.ValueList">
        <Record>
            <PropertyValue Property="CollectionPath" String="MarktSet"/>
            <PropertyValue Property="Parameters">
                <Collection>
                    <Record Type="Common.ValueListParameterOut">
                        <PropertyValue Property="LocalDataProperty" PropertyPath="MarktID"/>
                        <PropertyValue Property="ValueListProperty" String="ID"/>
                    </Record>
                    <Record Type="Common.ValueListParameterDisplayOnly">
                        <PropertyValue Property="ValueListProperty" String="Name"/>
                    </Record>
                </Collection>
            </PropertyValue>
        </Record>
    </Annotation>
</Annotations>

The question is how can I show the name of the selected item also in the drop down. I mean instead of showing 1300 (1300) (as can be seen in the picture) I want to show 1300 (Cimt Handelsgruppe) in the drop down itself.

It seems at the moment it does not know what to show in the parenthesis!?

Questioner
MJBZA
Viewed
0
MJBZA 2020-08-14 08:58:29

Eventually I found the solution!

Here is the definition of entity that contains the data regarding the drop-down:

<EntityType Name="Markt" sap:content-version="1">
    <Key>
        <PropertyRef Name="ID"/>
    </Key>
    <Property Name="ID" Type="Edm.String" Nullable="false" MaxLength="4" sap:display-format="UpperCase" sap:label="ID" sap:text="Name"/>
    <Property Name="Name" Type="Edm.String" Nullable="false" sap:label="Name"/>
</EntityType>

What was missing in my definition was sap:text="Name". By adding this small property the smart field know it has to show which property as description when the displayBehaviour is equal idAndDescription or descriptionAndId.

Finally I had what I wanted:

enter image description here