jDramaix/gwtchosen — pull request #121 by jDramaix (2014-03-11 13:11:38+00:00)
Title: Implement custom options filtering

An example of server side filtering :+1:
```java
public class ServerSideResultFilter implements ResultsFilter {
private boolean initialized;
private final TagProxy tagProxy;

public ServerSideResultFilter(TagProxy tagProxy) {
this.tagProxy = tagProxy;
}

@Override
public void filter(final String searchText, final ChosenImpl chosen, boolean isShowing) {
if (isShowing && initialized) {
return; // do nothing, keep the last results
}
initialized = true;

tagProxy.filterTags(searchText, new MethodCallback>() {
@Override
public void onSuccess(Method method, List tags) {
List selectItems = chosen.getSelectItems();
selectItems.clear();

for (Tag tag : tags) {
OptionItem optionItem = new OptionItem();
optionItem.setHtml("

" + tag.getLabel() +"" + tag.getCount() +"

");
optionItem.setText(tag.getLabel());
optionItem.setValue(tag.getLabel());
optionItem.setArrayIndex(tag.getId());
optionItem.setDomId("myOption_" + tag.getId());

selectItems.add(optionItem);
}

chosen.rebuildResultItems();
}
});

}
}

//...

ChosenOptions options = new ChosenOptions();
options.setResultFilter(new ServerSideResultFilter(tagProxy));
ChosenListBox chzn = new ChosenListBox(true, options);

//...
```