PDA

View Full Version : Strange ComboBox behaviour when expanded



sebbalex
13 Dec 2010, 1:15 PM
Hi all,
I've encountered a strange behaviour of ComboBox when I click on the down arrow to expand the list it looks like in fig below:

http://img338.imageshack.us/img338/7461/comboth.png

the elements inside the box seems are shallow, I don't know why, I tried to set some height properties unsuccesfully..

but, if I select an item it will be shown correctly on combo closure:

http://img404.imageshack.us/img404/8070/combo2b.png

Code:


public class ComboBoxImplant extends ComboBox {

public String valueCombo;
public String field;
ListStore<Implant> storeImplant;
List<Implant> implantList = new LinkedList<Implant>();

public ComboBoxImplant(String valueCombo, String field) {
this.valueCombo = valueCombo;
this.field = field;
}

public ComboBoxImplant() {
}

@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
loadData();
}

private PatchfinderAsync getService() {
PatchfinderAsync svc = (PatchfinderAsync) GWT.create(Patchfinder.class);
ServiceDefTarget endpoint = (ServiceDefTarget) svc;
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "patchList");
return svc;
}

public void loadData() {
AsyncCallback ac = new AsyncCallback() {

public void onFailure(Throwable caught) {
//error
MessageBox.info("VoipControl", "ComboBoxSite Loading Error", null);
}

public void onSuccess(Object result) {
if (result != null) {
implantList = (List<Implant>) result;
storeImplant = new ListStore<Implant>();
setEmptyText("Select a site...");
setTemplate(getTemplate());
storeImplant.add(implantList);
setStore(storeImplant);
setTypeAhead(true);
setTriggerAction(TriggerAction.ALL);
setDisplayField("name");
setValue(new Implant(valueCombo, field));
// setMaxHeight(100);
}
}
};
getService().implantList(valueCombo, ac);
}
}

thanks to eveyone!

sven
13 Dec 2010, 1:17 PM
How does the Implant class look like?

sebbalex
13 Dec 2010, 1:18 PM
Thanks for the quickness!

Implant:


public class Implant extends BaseModelData {

public Implant() {
}

public Implant(String name, String abbr) {
setAbbr(abbr);
setName(name);
}

public String getAbbr() {
return get("abbr");
}

public void setAbbr(String abbr) {
set("abbr", abbr);
}

public String getName() {
return get("name");
}

public void setName(String name) {
set("name", name);
}
}

sven
13 Dec 2010, 1:22 PM
Sorry missed that. You cannot change the displayfield and template after rendering which you do.

Move
setTypeAhead(true);
setTriggerAction(TriggerAction.ALL);
setDisplayField("name");
setEmptyText("Select a site...");
setTemplate(getTemplate());


out of the callback and put it into the contructor. Also remove
setTemplate(getTemplate()); because its not good.

sebbalex
13 Dec 2010, 1:26 PM
sven, now it works everything properly!
I really thank you!