Announcement

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

    ComboBoxItem doesn't allow value selection but retrieves data from the DataSource

    Need help with this correct usage of ComboBoxItem with a custom RPC based DataSource.

    Code:
    ComboBoxItem itemName = new WNGComboBoxItem();
    itemName.setOptionDataSource(extendedGwtRpcDataSource);
    The executeFetch() method of extendedGwtRpcDataSource retrieves
    the data from the server, creates ListGridRecord[] and sets the
    data using response.setData().
    When we click on the ComboBoxItem, it retrieves the data and
    populates the values correctly. However, when we select a value
    from the dropdown, that value is not selected (the selected value
    is always the last entry of the valueMap).

    We have 5 such ComboBoxItems on this screen and interesting thing
    is that we see this behavior only for 2 of them.
    We have tried setAddUnknownValues(false); and it doesn't seem to help.

    The logic was initially developed in smartgwt 2.3(? LGPL) version and it works fine with that smartgwt.jar file. When we use smartgwtpower.jar we see this behavior.

    Using v10.0p_2015-05-03/PowerEdition Deployment (built 2015-05-03)
    Last edited by leeyuiwah; 6 Aug 2015, 11:56.

    #2
    There's not much we can say with so little information. To take a guess, you may not have a primaryKey declared, or the valueField specified for the ComboBoxItem may not be unique in the records returned by the optionDataSource.

    Comment


      #3
      Originally posted by Isomorphic View Post
      There's not much we can say with so little information. To take a guess, you may not have a primaryKey declared, or the valueField specified for the ComboBoxItem may not be unique in the records returned by the optionDataSource.
      Thanks for the reply. Here is the code we have
      Code:
      final ComboBoxItem itemName = new ComboBoxItem();
      itemName.setName("mfr");
      itemName.setTitle("Manufacturer");
      
      itemName.setOptionDataSource(MfrDataSource);
      
      final ComboBoxItem itemName = new ComboBoxItem();
      itemName.setName("mfrName");
      itemName.setTitle("Manufacturer");
      
      itemName.setOptionDataSource(MfrDataSource);
      
      public class MfrDatasource extends GwtRpcDataSource {
          private String name = "mfrName";
          private String title = "Manufacturer";
          public MfrDatasource() {
          DataSourceTextField itemNameField = new DataSourceTextField(name, title, 128, true);
      	setFields(itemNameField);
          }
      
          @Override
          protected void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
              ServiceAsync ourService = GWT.create(OurService.class);
      	ourService.fetchAll(filterParam , new AsyncCallback<OurObject>() {
                  @Override
                  public void onFailure(Throwable caught) {
      		SC.say(caught.getMessage());
      	    }
      
                  @Override
      	    public void onSuccess(OurObject result) {
      	        ListGridRecord[] list = new ListGridRecord[result.size()+1];
      	        int i = 0;
      
      	        ListGridRecord r = new ListGridRecord();
      	        r.setAttribute(name, "");
      	        list[i++] = r;
                      while (result.getNext()) {
                          ListGridRecord record = new ListGridRecord();
                          record.setAttribute("mfrName", result.getMfr());
                          list[i++] = record;
                      }
                      response.setData(list);
      	        processResponse(requestId, response);
                 }
             }
          }
      }
      
      // On the backend we run the query
              select distinct manufacturer from MfrTable where ...;
      // So, we know select distinct manufacturer names (no duplicates). The data values do have blanks in them.
      And the behavior we see is that ComboBoxItem retrieves the data correctly and populates the data. However the problem is when we click on the ComboBoxItem and select an entity, it always picks the last entry in the dropdown.

      Interestingly the same logic worked fine in LGPL version of smartgwt 2.6.

      Comment


        #4
        Code:
        itemName.setDisplayField("mfrName");
        
        //Looks like adding the following line after that seems to  resolve the problem...
        itemName.setValueField(itemName.getDisplayField());
        Last edited by leeyuiwah; 7 Aug 2015, 06:22.

        Comment


          #5
          This still isn't enough for us to actually reproduce a problem (see the Debugging overview in docs for advice for creating test cases), but we can comment that yes, your values field and displayField settings do need to be there.

          Comment


            #6
            Originally posted by Isomorphic View Post
            This still isn't enough for us to actually reproduce a problem (see the Debugging overview in docs for advice for creating test cases), but we can comment that yes, your values field and displayField settings do need to be there.
            Sorry, I didn't make it clear. Adding the line
            Code:
            itemName.setValueField(...);
            has resolved the issue. We're good now. Thank you very much.

            Comment

            Working...
            X