PDA

View Full Version : [CLOSED] [2.0 M1] Filter field not filter DataList with DataListBinder



Webflash
8 May 2009, 7:26 AM
DataList not filtered



public class Catalog implements BeanModelTag
{
private static final long serialVersionUID = 1L;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}




ContentPanel catalogPanel = new ContentPanel(new FitLayout());
RpcProxy<List<Catalog>> proxy = new RpcProxy<List<Catalog>>() {
@Override
public void load(Object loadConfig, AsyncCallback<List<Catalog>> callback) {
List<Catalog> list = new ArrayList<Catalog>();
for (int i = 0; i < 10; i++) {
Catalog catalog = new Catalog();
catalog.setName(i + " Catalog name ");
list.add(catalog);
}
callback.onSuccess(list);
}
};
BeanModelReader reader = new BeanModelReader();
catalogLoader = new BaseListLoader<ListLoadResult<BeanModel>>(proxy, reader);
ListStore<BeanModel> store = new ListStore<BeanModel>(catalogLoader);

DataList catalogViewList = new DataList();
catalogViewList.setFlatStyle(true);
catalogBinder = new DataListBinder<BeanModel>(catalogViewList, store);
catalogBinder.setDisplayProperty("name");
catalogPanel.add(catalogViewList);
StoreFilterField<BeanModel> filter = new StoreFilterField<BeanModel>() {
@Override
protected boolean doSelect(Store<BeanModel> store, BeanModel parent, BeanModel record, String property,
String filter) {
String name = record.get("name");
name = name.toLowerCase();
if (name.startsWith(filter.toLowerCase())) {
return true;
}
return false;
}
};
filter.bind(store);
ToolBar toolBar = new ToolBar();
toolBar.add(filter);
catalogPanel.setTopComponent(toolBar);
Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());
viewport.add(catalogPanel);
RootPanel.get().add(viewport);

Webflash
8 May 2009, 8:01 AM
Sorry My mistake my Category model extend suoer clase which overide equel method wich check id for equel , I forgot setId in model when generete test data