I'm using a simple ComboBox in GXT that gets its values from the database.
What I want is that everytime that the user clicks (expands) the ComboBox, it will check and re-populate it with the latest entries in the database (in case they've changed).
Right now I'm doing something like:
ProtocolProperties protocolProperties = GWT.create(ProtocolProperties.class);
final ListStore<ProtocolDto> protocolStore = new ListStore<ProtocolDto>(protocolProperties.id());
protocol = new ComboBox<ProtocolDto>(protocolStore, protocolProperties.name());
protocol.addExpandHandler(new ExpandHandler() {
@Override
public void onExpand(ExpandEvent event) {
protocolStore.clear();
ProtocolDto emptyDto = new ProtocolDto();
emptyDto.setId(-1);
emptyDto.setName("None");
protocolStore.add(emptyDto);
AppEntryPoint.getLogbookdataservice().getAllProtocols(new AsyncCallback<List<ProtocolDto>>() {
@Override
public void onSuccess(List<ProtocolDto> result) {
protocolStore.addAll(result);
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
});
}
});
Thanks to anyone who takes the time to answer this.
You should be looking at Async Support in Combobox instead of reinventing a square wheel.
Sencha Demo - http://www.sencha.com/examples/#ExamplePlace:advancedcombobox
Stackoverflow - Also one approach discussed here - Dynamic Autosuggest Combobox in GXT