java - vaadin setItemCaptionPropertyId more then one caption in combobox -


i using beanitemcontainer fill combobox, :

//filling combobox userdto's beancontainer     beanitemcontainer<subcategorydto> beancontainer = new beanitemcontainer<subcategorydto>(             subcategorydto.class);     arraylist<subcategorydto> subcategorys = qpc.getsubcategorys();     beancontainer.addall(subcategorys);     cmbcategory.setcontainerdatasource(beancontainer);     cmbcategory.setitemcaptionmode(itemcaptionmode.id);     cmbcategory.setimmediate(true);     cmbcategory.setnewitemsallowed(false);     cmbcategory.setnullselectionallowed(false);     cmbcategory.setitemcaptionpropertyid("name"); 

the dto has following fields :

public class subcategorydto  extends observable implements serializable {  private static final long serialversionuid = 1l; private int subcategoryid; private string name; private categorydto category; ... 

i let itemcaption of combobox show both name , category name (dto has name field), : categoryname subcategoryname

is there way so? suggestion appreciated! thx

you can set item caption on combobox using itemcaptionmode.explicit , combo.setitemcaption(id, caption) or add read property bean:

public class subcategorydto {    private string name;   private categorydto parent;    public string getcaption() {     return parent.getname() + " " + name;   }  } 

and use itemcaptionmode.property , combo.setitemcaptionpropertyid("caption"). similarly, can put captioning logic inside overridden tostring() , use itemcaptionmode.item


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -