Announcement

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

    ComboBoxItem clears text after server round trip (IE only)

    Hi,
    This is a simple form with one item (comboBoxItem - unit). The form is connected to the one DataSource. The comboBoxItem has other, optionDataSource connected (UnitDir).
    Code:
    package pl.com.tech4.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.data.fields.DataSourceIntegerField;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.FormItemValueFormatter;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class MainEntryPoint implements EntryPoint {
     
        private DynamicForm df = null;
        private DataSource ds = null;
        private DataSource unitDS = null;
          
        public void onModuleLoad() {
            doLayout();
        }
      
        private void doLayout() {
            VLayout main = new VLayout();
          
            unitDS = new DataSource("UnitDir");
            unitDS.setRecordXPath("/response/data/UnitDir");
            DataSourceIntegerField idUnitField = new DataSourceIntegerField("id");
            idUnitField.setHidden(true);
            idUnitField.setPrimaryKey(true);
            DataSourceTextField codeField = new DataSourceTextField("code");
            unitDS.setFields(idUnitField, codeField);
            unitDS.setDataURL("UnitDir.xml");
            unitDS.setClientOnly(true);
          
            ds = new DataSource("ResourceUsed");
            DataSourceIntegerField idField = new DataSourceIntegerField("id");
            idField.setHidden(true);
            idField.setPrimaryKey(true);
            DataSourceTextField unitField = new DataSourceTextField("unit");
            unitField.setForeignKey("UnitDir.id");
            unitField.setValueXPath("unit/id");
            ComboBoxItem unitItem = new ComboBoxItem();
            unitItem.setDisplayField("code");
            unitItem.setValueField("id");
            unitItem.setOptionDataSource(unitDS);
            unitItem.setAddUnknownValues(false);
            unitField.setEditorProperties(unitItem);
            ds.setFields(idField, unitField);
          
            df = new DynamicForm();
            df.setDataSource(ds);
            main.addMember(df);
            main.draw();
        }
     
    }
    UnitDir.xml required to run the above sample:
    Code:
    <response>
        <requestId>UnitDir_request5</requestId>
        <startRow>0</startRow>
        <endRow>76</endRow>
        <totalRows>77</totalRows>
        <data>
            <UnitDir>
                <id>341</id>
                <code>kg</code>
                <description>kilogram</description>
                <validFrom>2015-05-26</validFrom>
                <validTo>2015-05-28</validTo>
            </UnitDir>
            <UnitDir>
                <id>342</id>
                <code>szt</code>
                <description>sztuki</description>
                <validFrom>2015-05-26</validFrom>
            </UnitDir>
            <UnitDir>
                <id>343</id>
                <code>sztuki</code>
                <description>sztuki</description>
                <validFrom>2015-05-26</validFrom>
            </UnitDir>
        </data>
        <requestedDataSource>UnitDir</requestedDataSource>
        <status>STATUS_SUCCESS</status>
    </response>
    If you run the sample on Chrome or Firefox then typing "s", "z" brings pickList with selection and the text "sz" stays as provided:
    Click image for larger version

Name:	unit_chrome54.gif
Views:	78
Size:	34.5 KB
ID:	241718
    But if you run it on IE (tested on 8 and 11) you will see that after typing "s", which triggers round trip to server, the typed letter "s" is swallowed. so only "z" remains.
    Click image for larger version

Name:	unit_ie11.gif
Views:	52
Size:	36.1 KB
ID:	241719

    To my understanding this happens during dataArrived event (on IE only).
    As above sample uses clientOnly DataSource, so dataArrived event occurs only once and all records are fetched. In the real application with true server responses with a lot of records, input text is cleared each time client sends request with modified criteria to the server. This makes such a comboBoxItem unusable in IE.

    Thanks,
    MichalG
    SGWT 6.0p/LGPL 2016-11-25
    IE 11.0.9600.18124 update 11.0.26
Working...
X