-
30 Nov 2011 4:59 AM #1
[FNR] TreeGrid sorting
[FNR] TreeGrid sorting
It seems like there is a TreeGrid sorting bug:
And here is the compiler error message:Code:private static final StockProperties props = GWT.create(StockProperties.class); private TreeGrid<Stock> tree; public void onModuleLoad() { TreeStore<Stock> store = new TreeStore<Stock>(props.key()); ColumnConfig<Stock, String> c = new ColumnConfig<Stock, String>(props.name(), 100, "Tree"); List<ColumnConfig<Stock, ?>> colList = new LinkedList<ColumnConfig<Stock, ?>>(); colList.add(c); tree = new TreeGrid<Stock>(store, new ColumnModel<Stock>(colList), c); tree.getTreeStore().addSortInfo(new StoreSortInfo<Stock>(props.sortindex(), SortDir.ASC)); // ERROR TextButton button = new TextButton("load"); button.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { clearAndLoadData(); } }); BorderLayoutContainer blc = new BorderLayoutContainer(); blc.setNorthWidget(button, new BorderLayoutData(50)); blc.setCenterWidget(tree); CustomViewport vp = new CustomViewport(); vp.add(blc); RootLayoutPanel.get().add(vp); } private void clearAndLoadData() { tree.getTreeStore().clear(); List<Stock> list = new LinkedList<GXT_3_0.Stock>(); Stock stock5 = new Stock("key5", "E (1)", 1); Stock stock3 = new Stock("key3", "C (3)", 3); Stock stock2 = new Stock("key2", "B (2)", 2); Stock stock4 = new Stock("key4", "D (4)", 4); Stock stock1 = new Stock("key1", "A (5)", 5); list.add(stock1); list.add(stock2); list.add(stock3); list.add(stock4); list.add(stock5); Stock root = new Stock("muh", "root", 0); tree.getTreeStore().add(root); for (Stock stock : list) tree.getTreeStore().add(root, stock); } interface StockProperties extends PropertyAccess<Stock> { ModelKeyProvider<Stock> key(); ValueProvider<Stock, String> name(); ValueProvider<Stock, Integer> sortindex(); } class Stock { public Stock(String key, String name, int sortindex) { this.key = key; this.name = name; this.sortindex = sortindex; } int sortindex = 0; String key = ""; String name = ""; public String getKey() { return key; } public void setKey(String key) { this.key = key; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getSortindex() { return sortindex; } public void setSortindex(int sortindex) { this.sortindex = sortindex; } }
I'm using the new SortInfo-Class to set the sort column (exact same thing works fine in a normal grid). I'm also using the getTreeStore() and not getStore() (noticed that in GXT2 already), so I don't know what other mistake I could have made.Caused by: java.lang.AssertionError: null
at com.sencha.gxt.data.shared.TreeStore$TreeModel.addChild(TreeStore.java:80)
at com.sencha.gxt.data.shared.TreeStore.insert(TreeStore.java:897)
at com.sencha.gxt.data.shared.TreeStore.add(TreeStore.java:330)
at nope.client.GXT_3_0.clearAndLoadData(GXT_3_0.java:79)
-
30 Nov 2011 10:25 AM #2
-
30 Nov 2011 5:40 PM #3
Hmm, appears we've got an invalid (and maybe nonsensical) assertion there. I'll review the code and reply back with some better answers. For now, it appears safe to modify the file by commenting out that assertion, and re-compiling that class.
Another workaround might be to disable sorting until all items are added, then re-apply the sort.
Yet another would be to disable assertions when running dev mode. This is a jvm arg, see http://docs.oracle.com/javase/1.4.2/...enable-disable for more details.
We've made some concerted efforts to optimize the tree operations, such as sorting and filter, especially as they apply to large numbers of nodes. I've liberally sprinkled asserts in the code to make sure assumptions made about how the tree is structured, which may affect dev mode performance, but will assure that all possible use cases function correctly.
-
6 Dec 2011 10:59 AM #4
Fix for this is in SVN. The main change, beyond moving the assert, was to add a little more logic for the general, non-filtered case.
Thanks for the report, and especially thanks for the great test case that came with it.
-
8 Dec 2011 2:52 AM #5
Big thanks for all the fixes you made. Keep it up!
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote