PDA

View Full Version : Async TreeGrid + Filter



sarsipius
28 Jul 2010, 4:19 AM
Hi,

I'm trying to use filter with an async TreeGrid.

The first column is an id for both node and leaf and the other columns are populated only for leafs

When I filter the first column, nodes are expander and I see all the leafs
But when I filter on other columns, the grid becomes empty even if I expand the node before

Can you help me?

Thanks

sven
28 Jul 2010, 4:20 AM
Can you help me?

You should post a testcase that implements EntryPoint. We dont know your code so we cannot help you much.

sarsipius
28 Jul 2010, 4:30 AM
I hope it will help:



RpcProxy<List<Exam>> proxy = new RpcProxy<List<Exam>>() {
protected void load(Object loadConfig, AsyncCallback<List<Exam>> callback) {
service.getReceivedExamList(study,(Exam)loadConfig,callback);
}
};

final TreeLoader<Exam> loader = new BaseTreeLoader<Exam>(proxy) {
public boolean hasChildren(Exam parent) {
return parent.getVisitname()!=null ? false : true;
}
};

store = new TreeStore<Exam>(loader);

List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

ColumnConfig column = null;

column = new ColumnConfig();
column.setId("subject");
column.setHeader("Subject");
column.setWidth(100);
column.setRenderer(new TreeGridCellRenderer<Exam>());
configs.add(column);

column = new ColumnConfig();
column.setId("visitname");
column.setHeader("Visitname");
column.setWidth(70);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);

ColumnModel cm = new ColumnModel(configs);

TreeGrid<Exam> tree = new TreeGrid<Exam>(store,cm);
tree.setBorders(false);
tree.getView().setForceFit(true);
new QuickTip(tree);

panel.add(tree);

StoreFilterField<Exam> subjectFilter = new StoreFilterField<Exam>() {
protected boolean doSelect(Store<Exam> store,Exam parent,Exam record,String property,String filter) {
if (record.getSubject().toString().toLowerCase().contains(filter.toLowerCase())) {
return true;
}
return false;
}
};
subjectFilter.setEmptyText("Subject");
subjectFilter.setWidth(100);
subjectFilter.bind(store);

StoreFilterField<Exam> visitnameFilter = new StoreFilterField<Exam>() {
protected boolean doSelect(Store<Exam> store,Exam parent,Exam record,String property,String filter) {
if(record.getVisitname()!=null && record.getVisitname().toString().toLowerCase().contains(filter.toLowerCase())) {
return true;
}
return false;
}
};
visitnameFilter.setEmptyText("Visitname");
visitnameFilter.setWidth(100);
visitnameFilter.bind(store);

ToolBar toolbar = new ToolBar();
toolbar.add(subjectFilter);
toolbar.add(new SeparatorToolItem());
toolbar.add(visitnameFilter);

panel.setTopComponent(toolbar);

add(panel)

sven
28 Jul 2010, 4:33 AM
Try to post a fully working testcase that implements EntryPoint and not only codesnippets that are not runnable.