문제

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!

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top