Threaded View
-
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)
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote