Announcement

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

    ComboBoxItem Bug?

    Smartgwt 2.4 with Firefox and others
    Hi,
    I got a strange thing with a ComboBoxItem :
    I have a comboBoxItem with it’s HashMap and a button which switch between two content for this hashMap.
    When I switch from one content of the HashMap to another one without doing any selection in the combo it works.
    As soon as I select something the switch doesn’t show up anymore(the content of the combo picking list is ok but no option show after the switch)
    Is it a bug?
    I saw also that I need to invoke redraw on the combo without it the switch doesn’t show up.

    Code:
    package albu.test.client;
    import com.google.gwt.core.client.EntryPoint;
    import java.util.LinkedHashMap;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
    import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class TestCombo implements EntryPoint {
    	
    	public void onModuleLoad() {
    		TestComboBoxItem cb = new TestComboBoxItem();
    		cb.draw();
    
    	}
    	public class TestComboBoxItem extends VLayout{
    		private boolean un = false;
    		private LinkedHashMap<String, String> sources = new LinkedHashMap<String, String>();
    		private  ComboBoxItem sourcesSelect = new ComboBoxItem();
    		public TestComboBoxItem(){
    
    			DynamicForm f = new DynamicForm();		
    			final ComboBoxItem sourcesSelect = new ComboBoxItem();
    			sourcesSelect.setTitle("Sources");
    			un = true;
    			sources.clear();						
    			sources.put("Base1","Base1");
    			sources.put("Base2","Base2");
    			sourcesSelect.setDefaultToFirstOption(true);
    			sourcesSelect.setValueMap(sources);
    			ButtonItem btnTest = new ButtonItem();
    			btnTest.setTitle("Base Switch");
    			btnTest.addClickHandler(new ClickHandler() {
    
    				@Override
    				public void onClick(ClickEvent event) {
    					if(!un){
    						un = true;
    						sources.clear();						
    						sources.put("Base1","Base1");
    						sources.put("Base2","Base2");
    						sourcesSelect.setDefaultToFirstOption(true);
    						sourcesSelect.setValueMap(sources);
    						sourcesSelect.redraw();
    						
    					}else{
    						un = false;
    						sources.clear();						
    						sources.put("NewBase1","NewBase1");
    						sources.put("NewBase2","NewBase2");
    						sources.put("NewBase3","NewBase3");	
    						sourcesSelect.setDefaultToFirstOption(true);
    						sourcesSelect.setValueMap(sources);
    						sourcesSelect.redraw();
    						
    					}
    				}
    			});		
    			
    			f.setItems(sourcesSelect,btnTest);
    			this.addMember(f);		
    		}		
    	}
    
    }

    #2
    Hi,

    I have the same problem.

    However, I do not use a button but an event that change the contents of the HashMap.

    Sorry, I have not solved this problem

    Regards,
    Francois.

    Comment

    Working...
    X