Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TreeGrid: filterData fails systematically complaining "(TypeError): _1 is undefined"

    Triggering TreeGrid.filterData() on a databound tree I get a com.google.gwt.core.client.JavaScriptException: (TypeError): _1 is undefined error message.
    Doing the same on a ListGrid works.
    Code:
    ...
    {//datasource fields initialization
        final DataSourceTextField keyField = new DataSourceTextField ("id", "ID");
        keyField.setPrimaryKey (true);
        final DataSourceFloatField parentIdField = new DataSourceFloatField ("parentId", "Parent ID");
        parentIdField.setForeignKey ("id");
        final DataSourceFloatField nameField = new DataSourceFloatField ("name", "Name");
        
        dataSource.setFields (keyField, parentIdField, nameField);
    }
    
    //UI initialization
    final TreeGrid treeGrid = new TreeGrid ();
    treeGrid.setAutoFetchData (true);
    treeGrid.setKeepParentsOnFilter (true);
    treeGrid.setDataSource (dataSource);
    //treeGrid.setLoadDataOnDemand (false);
    
    {
        final DynamicForm form = new DynamicForm();
        final TextItem searchItem = new TextItem();
        searchItem.addKeyPressHandler(new KeyPressHandler() {
    
            @Override
            public void onKeyPress(final KeyPressEvent event) {
                if ("Enter".equals(event.getKeyName())) {
    //              treeGrid.invalidateCache();
                    treeGrid.filterData(new AdvancedCriteria("name", OperatorId.ICONTAINS, searchItem.getValueAsString()));
                }
            }
        });
        searchItem.setTitle("Search");
        form.setItems(searchItem);
    }
    ...
    Disabling keepParentsOnFilter seems to fix the problem, but when I try to expand the last child node (actually a leaf) all rows are discarded. Enabling loadDataOnDemand rows are kept.
    So I have no way to filter a tree keeping the path to the root.

    [ATTACH]4782[/ATTACH] is a complete test case entry point.
    I've tested it on SmartGWT 3.1 [SmartClient Version: v8.3_2012-11-20/LGPL Development Only (built 2012-11-20)]

    #2
    Isomorphic, did I write a load of rubbish?
    Having a working tree filtered that still keeps parents would be really useful... did I miss something from docs?

    Comment


      #3
      I've found a workaround based on an external article.

      It basically creates new data tree copies applying custom filter logic.

      Comment


        #4
        Does anybody found a solution without using a second treegrid?
        My issue is similar to the one above. The thing is,
        Code:
        grid.setLoadDataOnDemand(false); 
        //grid.setDataFetchMode(FetchMode.LOCAL);
        //grid.setKeepParentsOnFilter(true);
        when filter button is pressed fetchdata is called, which is not the action I'm looking for. I want to achive client side filtering

        if one of the above commented sections are added to the code. When filter button is press the exception is thrown by SmartGWT,
        Code:
        "(TypeError): _1 is undefined"

        Comment

        Working...
        X