Announcement

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

    FilterBuilder.getCriteria() returns wrong value for fields rendered as ComboBoxItems

    [SmartClient Version: v11.0p_2016-10-01/PowerEdition Deployment (built 2016-10-01)] and [SmartClient Version: v10.0p_2016-02-18/PowerEdition Deployment (built 2016-02-18)]

    A field defined in a datasource with an _editorType_ of _ComboBoxItem_ returns the wrong value in _FilterBuilder.getCriteria() when the value has been set programatically and then not interacted with by the user.

    See the following rewrite of the BuildinDS sample. In it we assume there is a relationship between the animals and supplyItem datasources based on animals.commonName->supplyItem.SKU, as follows:

    Code:
            <field name="commonName"      title="Animal"             type="text" optionDataSource="supplyItem" valueField="SKU" displayField="itemName" editorType="ComboBoxItem"/>
    When the code is first run, the _showCriteria()_ method correctly shows us the criteria as "commonName IEQUALS 1087200". However, without doing anything else now click on the "Show Criteria" button and it shows us the criteria is "commonName IEQUALS Bostik Blu-tack Pkt 75gm". Now interact with the value by a selecting a value from the ComboBoxItem (including the currently selected item) and click "Show Criteria" again. This time it once again shows the correct "commonName IEQUALS 1087200" (or whatever SKU relates to the item selected item).

    It seems then that in some cases the valueField value is being returned, and in other cases we are getting back the displayField value.

    Now change the _editorType_ to _SelectItem_:

    Code:
            <field name="commonName"      title="Animal"             type="text" optionDataSource="supplyItem" valueField="SKU" displayField="itemName" editorType="SelectItem"/>
    If you perform the same test, you will always receive back criteria where the value contains the related SKU value.

    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.FilterBuilder;
    import com.smartgwt.client.widgets.layout.HLayout;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class BuiltInDS implements EntryPoint {
    
        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
            final FilterBuilder fb = new FilterBuilder();
            fb.setDataSource(DataSource.get("animals"));
            fb.setCriteria(new AdvancedCriteria("commonName", OperatorId.IEQUALS, "1087200"));
            
            IButton showCritBtn = new IButton("Show Criteria");
            showCritBtn .addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    showCriteria(fb);            }
            });
    
              HLayout hlayout = new HLayout();
              hlayout.setMembers(fb, showCritBtn);
              hlayout.draw();    
    
            showCriteria(fb);
        }
    
        private void showCriteria(final FilterBuilder fb) {
            Criterion crit = fb.getCriteria().getCriteria()[0];
            SC.say(crit.getFieldName() + " " + crit.getOperator() + " " + crit.getValueAsString());
        }
    }

    #2
    Just a quick update to let you know this is under investigation. We'll follow up properly as soon as we have more information / a resolution.

    Regards
    Isomorphic Software

    Comment


      #3
      We've made a change to address this issue in the 5.1 (SmartClient 10.1) and 6.0 (SmartClient 11.0) branches.
      Please try the next nightly build, dated October 7 or above

      Regards
      Isomorphic Software

      Comment


        #4
        Thank you - this is confirmed as working in the October 7 build of SmartGWT 6.0.

        Comment

        Working...
        X