Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    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:

    Code:
    ...
    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
    Code:
    <DataSource 
    ...
    >
    	<fields>
    		<field primaryKey="true" name="id" type="sequence"></field>
    		<field name="name" length="45" type="text"></field>
    	</fields>
    </DataSource>
    DSProfile.ds.xml
    Code:
    ...
    <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>

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

    Comment


      #3
      Hi svjard,

      thanks for the fast answer.
      I already set this method (I forgot to write it before):
      Code:
      clientSel.setDisplayField("description");
      But it doesnīt work. Iīm missing something here?

      Comment


        #4
        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?

        Comment


          #5
          Hi svjard,

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

          Code:
          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!

          Comment


            #6
            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
            Last edited by Driftdone; 27 Jun 2011, 23:14.

            Comment

            Working...
            X