Display NAME instead of ID using setPickListFields in SelectItem does NOT work!

Hi folks,

I have two tables (Client and Profile) with the following columns:
Client: ID, NAME
Profile: CLIENT_ID, PROFILE_NAME

Now, I have a combobox to display all client profiles.
But instead of the client id, I want to see her/his name.

This works perfect in a table with a ListGrid
but using setPickListFields in a SelectItem does not bring the client name, just the ID. Why?

Here is some code and thanks in advance:

...
ListGridField clientField = new ListGridField("client");
clientField.setWidth(35);
clientField.setOptionDataSource(DataSource.get("DSClient"));
clientField.setDisplayField("description");
...

// I think here is the mistake, this overrides everything!
// But I don´t know any other way
clientSel.setOptionOperationId("getMyProfiles");	
clientSel.setOptionDataSource(DataSource.get("DSProfile"));

clientSel.setPickListFields(clientField);

DSClient.ds.xml

<DataSource 
...
>
	<fields>
		<field primaryKey="true" name="id" type="sequence"></field>
		<field name="name" length="45" type="text"></field>
	</fields>
</DataSource>

DSProfile.ds.xml

...
<fields>
	<field primaryKey="true" name="client_id" foreignKey="DSClient.id" type="number"></field>
	<field title="Profile name"  name="profile_name" type="text"></field>
...
<operationBindings>
	<operationBinding operationType="fetch" operationId="getMyProfiles" requiresAuthentication="true">
		<criteria fieldName="userid" value="$servletRequest.remoteUser"/>
    		<whereClause>payfits.profile.client != '' AND payfits.profile.secGroup != 'admin' AND ($defaultWhereClause)</whereClause>
	</operationBinding>
</operationBindings>

SelectItem supports similiar methods you need to set, SelectItem.setDisplayField() and SelectItem.setValueField().

Hi svjard,

thanks for the fast answer.
I already set this method (I forgot to write it before):

clientSel.setDisplayField("description");

But it doesn´t work. I´m missing something here?

So this SelectItem is just part of a form correct? If you use the same Datasource as your using on the grid which you said work, does it work on your SelectItem?

Hi svjard,

yes it works with the ListGrid but NOT in the SelectItem.
I use the same DataSource:

ListGridField client = new ListGridField("client");
client.setOptionDataSource(DataSource.get("DSClient"));
client.setDisplayField("description");
 
final ListGrid profileGrid = new ListGrid();  
profileGrid.setDataSource(DataSource.get("DSProfile"));  
...
// Works perfect!
profileGrid.setFields(client,operator, secGroup, application, environment);

But in the SelectItem itself I CANNOT set any DataSource but only an OptionDataSource!

Did you managed to find a solution for displaying the name instead of the code in the ListGrid and NOT only in the comboBox that appears when you modify the value?

Thank you for your answers,
Driftdone