Question

I have an object with two essential fields that must be displayed for the user together in ComboBox something kind of:

 MyObject { 
            Long id;
            Integer from;
            Integer to;
            ...
          }

My properties look like :

 MyObjectProperties { 
            ModelKeyProvider<MyObject> id();
            LabelProvider<MyObject> from();
            LabelProvider<MyObject> to();
            ...
          }

I'm trying to display **from - to** in each combobox cell, is it possible using GXT 3 ComboBox?

That's not working for me because i can't use LabelProvider for an int and can't merge two wroperties in same field!

Était-ce utile?

La solution

LabelProvider is in fact the only clean way to go, but you need only one LabelProvider:

LabelProvider<MyObject> labelProvider = new LabelProvider<MyObject>(){
    @Override
    public String getLabel(MyObject item){
        return item.getFrom() + " - " + item.getTo();
    }
}

And assign it at ComboBox creation time:

ComboBox<MyObject> cb = new ComboBox<MyObject>(store, labelProvider);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top