PDA

View Full Version : TreeGrid setExpandOnFilter(false) after filtering don't open leafs



peterarsentev
17 Feb 2012, 2:48 AM
Hello I have a strange behavior in TreeGrid when I set setExpandOnFilter(false). It does not open leafs after filtering.
I made a maven project where you can testing it.
http://www.2shared.com/file/sP9XAVt2/TreeMX.html

How to repeat bug.
1. unpack
2. go to TreeMX
3. mvn gwt:run
4. inter 0 in filters field
5. try to open node after filtering.

Please check it and fix it.

Regard.

sven
18 Feb 2012, 1:50 AM
Can you please post just the required EntryPoint class as plain text here?

The testcase should just be a single class implementing EntryPoint.

peterarsentev
27 Feb 2012, 4:21 AM
Yes sure


package com.sample.tree.client;


import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sample.tree.client.model.TopMXItem;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.Store;
import com.sencha.gxt.data.shared.TreeStore;
import com.sencha.gxt.widget.core.client.button.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.FlowLayoutContainer;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.StoreFilterField;
import com.sencha.gxt.widget.core.client.tree.Tree;


public class TreeMX implements IsWidget, EntryPoint {


class KeyProvider implements ModelKeyProvider<TopMXItem> {
public String getKey(TopMXItem item) {
return item.get("id");
}
}


public Widget asWidget() {
FlowLayoutContainer con = new FlowLayoutContainer();


TreeStore<TopMXItem> store = new TreeStore<TopMXItem>(new KeyProvider());
for (int i=0;i!=10;++i) {
TopMXItem item = new TopMXItem(String.valueOf(i), "parent"+i);
store.add(item);
processFolder(store, item);
}


StoreFilterField<TopMXItem> filter = new StoreFilterField<TopMXItem>() {
@Override
protected boolean doSelect(Store<TopMXItem> topMXItemStore, TopMXItem topMXItem, TopMXItem topMXItem1, String s) {
return topMXItem1.get("name").toString().contains(s);
}
};
filter.bind(store);


final Tree<TopMXItem, String> tree = new Tree<TopMXItem, String>(store, new ValueProvider<TopMXItem, String>() {


public String getValue(TopMXItem object) {
return object.get("name");
}


public void setValue(TopMXItem object, String value) {
}


public String getPath() {
return "name";
}
});
tree.setExpandOnFilter(true);
tree.setWidth(300);
ButtonBar buttonBar = new ButtonBar();


buttonBar.add(new TextButton("Expand All", new SelectHandler() {
public void onSelect(SelectEvent event) {
tree.expandAll();
}
}));
buttonBar.add(new TextButton("Collapse All", new SelectHandler() {
public void onSelect(SelectEvent event) {
tree.collapseAll();
}
}));


buttonBar.setLayoutData(new MarginData(4));
con.add(filter);
con.add(buttonBar);
con.add(tree);
return con;
}


public void onModuleLoad() {
RootPanel.get().add(asWidget());
}


private void processFolder(TreeStore<TopMXItem> store, TopMXItem item) {
for (int i=0;i!=10;++i) {
TopMXItem child = new TopMXItem(item.get("id") + String.valueOf(i), String.valueOf(i));
store.add(item, child);
}
}
}

peterarsentev
29 Feb 2012, 5:04 AM
Can you tell me anything about this problem?