Problem with ComboBoxItem and empty string descriptions - ChangedHandler is being called early.
I have included an example of this -
The first drop down just changes a description field on a record you select to “” … if this isn’t done the problem doesn’t show up.
The second drop down box has a changedHandler …. and it is fired [early] as soon as it is dropped down - you do not need to select a record first!
Note: it doesn’t need to be changed to an empty string in the same session … the data can already be like that …. it just made it a bit easier (I think) to demonstrate it in my test case.
In an ideal world I wouldn’t have datasets with empty strings present - but sadly I do do at the moment in some places.
The file is designed to just overwrite the BuiltInDS.java file in the BuiltInDS sample and work with no other changes.
Code:
My version is: v10.0p_2014-10-01/Pro Deployment (built 2014-10-01)
Version 4.1 [Pro/2014-10-04] does not show this behaviour.
Thank-you very much in advance.
I have included an example of this -
The first drop down just changes a description field on a record you select to “” … if this isn’t done the problem doesn’t show up.
The second drop down box has a changedHandler …. and it is fired [early] as soon as it is dropped down - you do not need to select a record first!
Note: it doesn’t need to be changed to an empty string in the same session … the data can already be like that …. it just made it a bit easier (I think) to demonstrate it in my test case.
In an ideal world I wouldn’t have datasets with empty strings present - but sadly I do do at the moment in some places.
The file is designed to just overwrite the BuiltInDS.java file in the BuiltInDS sample and work with no other changes.
Code:
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ComboBoxItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.grid.ListGridRecord; public class BuiltInDS implements EntryPoint { @Override public void onModuleLoad() { final DynamicForm form = new DynamicForm(); form.setWidth(500); final DataSource ds = DataSource.get("supplyItem"); final ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.setName("filteredCombo"); comboBoxItem.setAddUnknownValues(false); comboBoxItem.setOptionDataSource(ds); comboBoxItem.setDisplayField("description"); comboBoxItem.setValueField("itemID"); comboBoxItem.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { ListGridRecord rec = comboBoxItem.getSelectedRecord(); rec.setAttribute("description", ""); ds.updateData(rec); } }); ComboBoxItem comboBox2 = new ComboBoxItem(); comboBox2.setName("filteredCombo2"); comboBox2.setTitle("Choose an item (ComboBox)"); comboBox2.setAddUnknownValues(false); comboBox2.setOptionDataSource(ds); comboBox2.setDisplayField("description"); comboBox2.setValueField("itemID"); comboBox2.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { SC.say("Changed!"); } }); form.setFields(comboBoxItem, comboBox2); form.draw(); } }
My version is: v10.0p_2014-10-01/Pro Deployment (built 2014-10-01)
Version 4.1 [Pro/2014-10-04] does not show this behaviour.
Thank-you very much in advance.
Comment