1. #1
    Ext User
    Join Date
    Jun 2008
    Location
    Brasil
    Posts
    36
    Vote Rating
    0
    rgpinheiro is on a distinguished road

      0  

    Default [OPEN] ComboBox doesn't shown properly

    [OPEN] ComboBox doesn't shown properly


    here we go again...

    while trying to set the display field with an attribute that belongs to an object of my ModelData ComboBox, the data are not shown correctly

    here the code:
    Code:
    import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
    import com.extjs.gxt.ui.client.store.ListStore;
    import com.extjs.gxt.ui.client.widget.Dialog;
    import com.extjs.gxt.ui.client.widget.form.ComboBox;
    import com.extjs.gxt.ui.client.widget.form.FormPanel;
    import com.google.gwt.core.client.EntryPoint;
    
    public class Index implements EntryPoint {
        
        private ComboBox<Person> comboBox;
        private Person person1;
        private FormPanel formPanel;
        private Dialog dialog;
        private Person person2;
        private Address address1;
        private Address address2;
        
        public void onModuleLoad() {
            
            Long i = new Long(3);
        
            person1 = new Person();
            person1.setId(1);
            person1.setName("Rafael");
            person1.setPersonCode(i);
    
            address1 = new Address();
            address1.setId(332);
            address1.setStreetName("First Heaven");
            address1.setStreetNumber(i+10);
    
            person1.setAddress(address1);
            //======================
            
            person2 = new Person();
            person2.setId(2);
            person2.setName("Offspring");
            person2.setPersonCode(i+1);
    
            address2 = new Address();
            address2.setId(32);
            address2.setStreetName("Times Square");
            address2.setStreetNumber(i+20);
    
            person2.setAddress(address2);
            //======================
            
            ListStore<Person> listPerson = new ListStore<Person>();
            listPerson.add(person1);
            listPerson.add(person2);
            
            dialog = new Dialog();
            dialog.setWidth(400);
            dialog.setHeight(200);
            
            formPanel = new FormPanel();
            formPanel.setHeaderVisible(false);
            formPanel.setFrame(true);
            formPanel.setFieldWidth(110);  
            formPanel.setLabelWidth(100);  
            formPanel.setButtonAlign(HorizontalAlignment.CENTER);  
            formPanel.setWidth("100%");
            
            comboBox = new ComboBox<Person>();
            comboBox.setStore(listPerson);
            comboBox.setDisplayField("address.streetName");
            
            comboBox.setFieldLabel("Person cod:");
            
            formPanel.add(comboBox);
            dialog.add(formPanel);
            
            dialog.show();
        }
    
    }
    Code:
    import com.extjs.gxt.ui.client.data.BaseTreeModel;
    
    public class Person extends BaseTreeModel {
    
        private static final long serialVersionUID = -7506205164127602576L;
        
            private int id;
            private String name;
            private Long personCode;
            private Address personAddress;
            
            public Person(){
                
            }
            
            public int getId() {
                return get("id");
            }
            
            public void setId(int id) {
                set("id", id);
            }
            
            public String getName() {
                return get("name");
            }
            
            public void setName(String name) {
                set("name",  name);
            }
            
            public Long getPersonCode() {
                return get("personCode");
            }
            
            public void setPersonCode(Long personCode) {
                set("personCode", personCode);
            }
    
            public Address getAddress() {
                return get("personAddress");
            }
    
            public void setAddress(Address personAddress) {
                set("personAddress", personAddress);
            }
            
    }
    Code:
    import com.extjs.gxt.ui.client.data.BaseTreeModel;
    
    public class Address extends BaseTreeModel {
    
        private static final long serialVersionUID = 1387724684937498499L;
    
        private int id;
        private String streetName;
        private Long streetNumber;
        
        public int getId() {
            return id;
        }
        
        public void setId(int id) {
            this.id = id;
        }
        
        public String getStreetName() {
            return streetName;
        }
        
        public void setStreetName(String streetName) {
            this.streetName = streetName;
        }
        
        public Long getStreetNumber() {
            return streetNumber;
        }
        
        public void setStreetNumber(Long streetNumber) {
            this.streetNumber = streetNumber;
        }
        
    }

  2. #2
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    First, please post your sample code as a single class. Second, you have 2 bugs in your code.

    1. You are setting the address as "personAddress" not "address".
    2. You Address pojo is not using get and set internally which is required.

  3. #3
    Ext User
    Join Date
    Jun 2008
    Location
    Brasil
    Posts
    36
    Vote Rating
    0
    rgpinheiro is on a distinguished road

      0  

    Default


    We've make the changes you tell, but doesn't work...

    I'll post again the simple class code:

    Code:
    import java.io.Serializable;
    import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
    import com.extjs.gxt.ui.client.data.BaseTreeModel;
    import com.extjs.gxt.ui.client.store.ListStore;
    import com.extjs.gxt.ui.client.widget.Dialog;
    import com.extjs.gxt.ui.client.widget.form.ComboBox;
    import com.extjs.gxt.ui.client.widget.form.FormPanel;
    import com.google.gwt.core.client.EntryPoint;
    
    public class Index implements EntryPoint {
        
        private ComboBox<A> comboBox;
        private FormPanel formPanel;
        private Dialog dialog;
        
        public void onModuleLoad() {
            A a = new A();
            B b = new B();
            b.setC("test");
            a.setB(b);
            
            ListStore<A> listPerson = new ListStore<A>();
            listPerson.add(a);
            
            dialog = new Dialog();
            dialog.setWidth(400);
            dialog.setHeight(200);
            
            formPanel = new FormPanel();
            formPanel.setHeaderVisible(false);
            formPanel.setFrame(true);
            formPanel.setFieldWidth(110);  
            formPanel.setLabelWidth(100);  
            formPanel.setButtonAlign(HorizontalAlignment.CENTER);  
            formPanel.setWidth("100%");
            
            comboBox = new ComboBox<A>();
            comboBox.setStore(listPerson);
            comboBox.setDisplayField("b.c");
            
            comboBox.setFieldLabel("Attribute C of Class B that belong to class A");
            
            formPanel.add(comboBox);
            dialog.add(formPanel);
            
            dialog.show();
        }
        
        private class A extends BaseTreeModel implements Serializable {
            public void setB(B b) {
                set("b", b);
            }
            
            public B getB(){
                return get("b");
            }
        }
        
        private class B extends BaseTreeModel implements Serializable {
            public void setC(String c) {
                set("c", c);
            }
            
            public String getC(){
                return get("c");
            }
        }
    }

  4. #4
    Ext User
    Join Date
    Jun 2008
    Location
    Brasil
    Posts
    36
    Vote Rating
    0
    rgpinheiro is on a distinguished road

      0  

    Default


    - GXT 1.0. RC2
    - hosted GWT browser
    - Ubuntu 8.04

  5. #5
    Ext User
    Join Date
    Jun 2008
    Location
    Brasil
    Posts
    36
    Vote Rating
    0
    rgpinheiro is on a distinguished road

      0  

    Default


    somebody knows what I can do?

  6. #6
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    The Template class does not support nested objects. Combo uses the Template class, so you will have to "flatten" your data for use in Combo. I am marking this post as open to be addressed at a later time.

  7. #7
    Ext User
    Join Date
    Jun 2008
    Location
    Brasil
    Posts
    36
    Vote Rating
    0
    rgpinheiro is on a distinguished road

      0  

    Default


    Ok... I'll wait

    Thanks

  8. #8
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

    Default


    any suggest to solve this problem?

  9. #9