Announcement

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

    SelectItem displays valuefield sometimes

    I have a problem with a SelectItem that sometimes displays the valuefield instead of the displayfield. The attached image shows an example where the field "Estimator" shows the valuefield (10) instead of the the displayfield (an email address) which it should display. This happes approx. 1/20 times.

    the src for the selectitem:
    Code:
    DataSource estimatorDS =  DataSource.get("selectiveUsers");
    SelectItem estimatorId = new SelectItem("estimatorId");
    estimatorId.setTitle("Estimator");
    estimatorId.setDisplayField("email");
    estimatorId.setValueField("id");
    estimatorId.setWidth(fieldWidth);
    estimatorId.setOptionDataSource(estimatorDS);
    I have also tried this manual way:
    Code:
    DataSource estimatorDS =  DataSource.get("selectiveUsers");
    estimatorDS.fetchData(null, new DSCallback() {
    	@Override
    	public void execute(DSResponse response, Object rawData, DSRequest request) {
    		estimatorId.setValueMap((LinkedHashMap) response.getDataAsRecordList().getValueMap("id", "email"));
    	}
    });
    
    estimatorId = new SelectItem("estimatorId");
    estimatorId.setTitle("Estimator");
    estimatorId.setDisplayField("email");
    estimatorId.setValueField("id");
    estimatorId.setWidth(fieldWidth);
    estimatorId.setValueMap(estimators);

    My datasource:
    Code:
    <DataSource  
        ID="selectiveUsers"
        serverConstructor="com.emp.server.servlets.user.UserServlet">
        <fields>
            <field name="id"                   type="sequence"      hidden="true"                          primaryKey="true"/>
            <field name="userName"             type="text"          title="User Name"                      required="true"  />
            <field name="email"                type="text"          title="Email"                          required="true"  />
    	</fields>
    </DataSource>
    Can anyone help with this?

    I use SmartGWT 3.0 and it occurs in all of the major browsers.
    Attached Files

    #2
    Generally speaking this would be because the server failed to return the displayField for the valueField, and it seems to be doing so intermittently. See the docs for selectItem.fetchMissingValues, and if you can reproduce the issue, check the RPC tab to see if you can find a request that failed or returned wrong data.

    Comment


      #3
      As far as I can see it is not because the server fails to send correct data back to the client.

      The RPC response for a case similar to the attached image is:

      Code:
      [
          {
              data:[
                  {
                      email:"jp@empgroup.net", 
                      id:4, 
                      rights:1
                  }, 
                  {
                      email:"mg@empgroup.net", 
                      id:10, 
                      rights:1
                  }, 
                  {
                      email:"ma@empgroup.net", 
                      id:11,  
                      rights:1
                  }
              ], 
              invalidateCache:false, 
              isDSResponse:true, 
              operationType:"fetch", 
              queueStatus:0, 
              status:0
          }
      ]
      You asked me to look into selectItem.fetchMissingValues, but I assume that this is not relevant since the server response is correct. Am I wrong?

      Comment


        #4
        Another thing to check is whether the field you're using as a valueField is unique across all records the server may return. It is required to be.

        If this doesn't reveal the issue, we'll need a runnable test case that reproduces the problem, as we have no similar reports of intermittent failures.

        Comment

        Working...
        X