0

I'm using Vaadin ComboBox in my Project and now I've got a new problem, which don't allows me to open the Combo's list after clicking on the ComboBox or on the DropDown Icon! I can type in the ComboBox and with arrow keys from the keyboard I can open the ComboBox list but not with clicking. I found out, when I hold my mouse pointer in a specific area top on the ComboBox, the pointer will change to a Hand and then I can open the list with clicking but just in that case and it happends rare that i can focus the mouse pointer on that area, it's like a small dot on the whole ComboBox.

And the Only code I am using for this ComboBox is, EDITED:

public class ChildElement extends OgsAbstractForm<Child> {

    @Inject
    ChildFacade childFacade;

    ComboBox cbChild=new ComboBox();
    HorizontalLayout mainLayout=new MHorizontalLayout();

@Override
protected Component createContent() {

    List<Child> children=new ArrayList<Child>();
    children.addAll(childFacade.findAll());

    for(int i=0;i<children.size();i++){
        cbChild.addItem(children.get(i).getName());
    }

    cbChild.select(children.get(0).getName());

    cbChild.setFilteringMode(FilteringMode.CONTAINS);


    mainLayout.addComponent(cbChild);
    return mainLayout;
}

}

And then I'm using this element in a View like below,

public class OGSVertragView extends CssLayout implements View{

@Inject
ChildElement childElement;

VerticalLayout main=new VerticalLayout();

@PostConstruct
void init() {

    main.addComponent(childElement);

    addComponents(main);

}
}

It would be really nice, when someone could somehow give me a clue or helps me.

Best Regards!

Reza P.
  • 306
  • 2
  • 18

1 Answers1

0

Looks for me like your ComboBox doesn't have enough space. Try setting mainLayoutheight like 200-300 px, and make sure your VerticalLayout main will give enough space to `mainLayout. Also try adding:

cbChild.setImmediate(true);

+ Small tip about initializing variables

Dawid Fieluba
  • 1,271
  • 14
  • 34
  • Thanks alot! It wasn'T `cbChild.setImmediate(true);` but the width, cbChild had a Width size as 100% and also its parent layout. – Reza P. Sep 26 '17 at 12:30
  • I just changed the width instead of 100% to 100px and it works. – Reza P. Sep 26 '17 at 12:31
  • but how can I do it with percentage instead of pixel? Any Idea? – Reza P. Sep 26 '17 at 12:31
  • Setting width/height to 100% means that you use all available space from parent layout. So in `OGSVertragView` you can make CssLayout full sized, like this: `super.setSizeFull();`. And also take care of `VerticalLayout main` size. – Dawid Fieluba Sep 26 '17 at 12:44