Hybrid View

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    54
    Vote Rating
    0
    DarekKay is on a distinguished road

      0  

    Default [FNR] TreeGrid sorting

    [FNR] TreeGrid sorting


    It seems like there is a TreeGrid sorting bug:

    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;
            }
        }
    And here is the compiler error message:
    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)
    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.

  2. #2
    Sencha User
    Join Date
    Jan 2009
    Location
    US
    Posts
    46
    Vote Rating
    0
    zlog is on a distinguished road

      0  

    Default


    I'm also interested about this.

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,717
    Vote Rating
    89
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    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.

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,717
    Vote Rating
    89
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    54
    Vote Rating
    0
    DarekKay is on a distinguished road

      0  

    Default


    Big thanks for all the fixes you made. Keep it up!

Thread Participants: 2