Announcement

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

    MultiComboBoxItem layoutStyle does not work

    Tested on:
    smartgwtpower-3.1p, latest nightly
    FireFox 16.0.2

    When trying out other MultiComboBoxLayoutStyles than the default FLOW, the previously selected values are not cleared when programmaticly setting new values to a MultiComboBoxItem.

    Test case:
    If one clicks on a record in the listgrid, the selected record will be edited in the dynamicform. The 'users' from the grid will be shown in the MultiComboBoxItem. Then if one clicks another record, the new users will be added to the MultiComboBoxItem, but the ones from the previous record are still present.

    Entrypoint module
    Code:
    package test.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.types.MultiComboBoxLayoutStyle;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.MultiComboBoxItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
    import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class Test implements EntryPoint {
    
    	private VLayout vlayout = new VLayout();
    	private HLayout hlayout = new HLayout();
    	private ListGrid listGrid = new ListGrid();
    	private DynamicForm form = new DynamicForm();
    
    	public void onModuleLoad() {		
    		vlayout.setWidth100();
    		vlayout.setHeight100();
    		
    		listGrid.setDataSource(ContentDS.getInstance());
    		listGrid.setAutoFetchData(true);
    		ListGridField idField = new ListGridField("cntn_id");
    		ListGridField usersField = new ListGridField("users");
    		usersField.setOptionDataSource(UserDS.getInstance());
    		usersField.setValueField("user_pk");
    		usersField.setDisplayField("user_userName");
    		listGrid.setFields(idField, usersField);
    		listGrid.addRecordClickHandler(new RecordClickHandler() {			
    			@Override
    			public void onRecordClick(RecordClickEvent event) {
    				form.editRecord(event.getRecord());				
    			}
    		});
    		
    		form.setDataSource(ContentDS.getInstance());
    		TextItem idItem = new TextItem("cntn_id");
    		MultiComboBoxItem usersItem = new MultiComboBoxItem("users");
    		usersItem.setOptionDataSource(UserDS.getInstance());
    		usersItem.setValueField("user_pk");
    		usersItem.setDisplayField("user_userName");
    		usersItem.setLayoutStyle(MultiComboBoxLayoutStyle.VERTICAL);
    		form.setFields(idItem, usersItem);
    
    		hlayout.addMember(listGrid);
    		hlayout.addMember(form);
    		vlayout.addMember(hlayout);		
    		vlayout.draw();
    	}
    }
    DataSources:
    Code:
    package test.client;
    
    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;
    
    public class ContentDS extends DataSource {
    
    	private static ContentDS instance = null;
    
    	public static ContentDS getInstance() {
    		if (instance == null) {
    			instance = new ContentDS("contentDS");
    		}
    		return instance;
    	}
    
    	private ContentDS(String id) {
    		setID(id);
    		
    		DataSourceIntegerField pkField = new DataSourceIntegerField("cntn_pk");  
            pkField.setHidden(true);  
            pkField.setPrimaryKey(true);
    		
    		DataSourceTextField idField = new DataSourceTextField("cntn_id");
    
    		DataSourceIntegerField usersField = new DataSourceIntegerField("users");
    		usersField.setMultiple(true);
    
    		setFields(pkField, idField, usersField);
    
    		setClientOnly(true);
    		
    		setTestData(
    				new ContentRecord(1, "001", 1, 2),
    				new ContentRecord(2, "002", 3, 4),
    				new ContentRecord(3, "003", 3));
    	}
    
    	private class ContentRecord extends Record {
    		public ContentRecord(Integer pk, String id, Integer... users) {
    			setAttribute("cntn_pk", pk);
    			setAttribute("cntn_id", id);
    			setAttribute("users", users);
    		}		
    	}
    }
    Code:
    package test.client;
    
    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;
    
    public class UserDS extends DataSource {
    
    	private static UserDS instance = null;
    
    	public static UserDS getInstance() {
    		if (instance == null) {
    			instance = new UserDS("userDS");
    		}
    		return instance;
    	}
    
    	private UserDS(String id) {
    		setID(id);
    		
    		DataSourceIntegerField pkField = new DataSourceIntegerField("user_pk");  
            pkField.setHidden(true);  
            pkField.setPrimaryKey(true);
    		
    		DataSourceTextField idField = new DataSourceTextField("user_userName");
    		
    		setFields(pkField, idField);
    
    		setClientOnly(true);
    		
    		setTestData(
    				new UserRecord(1, "Jan"),
    				new UserRecord(2, "Piet"),
    				new UserRecord(3, "Joris"),
    				new UserRecord(4, "Korneel"));
    	}
    	
    	private class UserRecord extends Record {
    		public UserRecord(Integer pk, String id) {
    			setAttribute("user_pk", pk);
    			setAttribute("user_userName", id);
    		}		
    	}
    }

    #2
    Thanks for the clear test case. This is fixed for tomorrow's builds.

    Comment

    Working...
    X