If I have understood your intention right, you have slight error with logic there. You are trying to set filter only when the text field is empty, hence having filter with no effect. You should add not-operator in your if-clause. I.e. if(!filterTextField.getValue.equals(“”) { … }
Thanks, but i’m on a project my manager give to me, and said me to not use addons.
I’ts working now:
[code]
HeaderCell cell = headerRow.getCell(pid);
final TextField filterTextField = new TextField();
filterTextField.setImmediate(true);
filterTextField.setInputPrompt("Filtre");
filterTextField.addStyleName(ValoTheme.TEXTFIELD_TINY);
filterTextField.addTextChangeListener(new TextChangeListener() {
private static final long serialVersionUID = 1L;
@Override
public void textChange(TextChangeEvent event) {
Filterable filter = (Filterable) getGrid().getContainerDataSource();
filter.removeAllContainerFilters();
if(event.getText().length() > 0){
filter.addContainerFilter(new SimpleStringFilter(pid, event.getText(), true, false));
}
}
});
cell.setComponent(filterTextField);
[/code]The real problem was i used
beans.addContainerFilter(new SimpleStringFilter(pid,
filterTextField.getValue(), true, false));
instead of
filter.addContainerFilter(new SimpleStringFilter(pid,
event.getText(), true, false));
Sometime I really not understand vaadin logic…
Two functions, normally the same result, but one say null
@Tatu Lund: Thanx, it was useful, even if the problem wasn’t here, your save me an half of an hour!