2017-06-14 25 views
0

你好朋友我正在开发一个GWT应用程序,我正在使用TreeGrid。当我在这个矿类使用规则的网格状:如何刷新GWT中的TreeGrid?

RpcProxy<ListLoadResult<GwtDatastoreAsset>> proxy = new RpcProxy<ListLoadResult<GwtDatastoreAsset>>() { 

      @Override 
      protected void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtDatastoreAsset>> callback) { 
       if (selectedDevice != null) { 
       dataService.findAssets((LoadConfig) loadConfig, currentSession.getSelectedAccount().getId(), selectedDevice, callback); 
       } 
      } 
     }; 

     loader = new BaseListLoader<ListLoadResult<GwtDatastoreAsset>>(proxy); 
     loader.load(); 
     SwappableListStore<GwtDatastoreAsset> store = new SwappableListStore<GwtDatastoreAsset>(loader); 
     assetGrid = new Grid<GwtDatastoreAsset>(store, new ColumnModel(configs)); 
     assetGrid.setBorders(false); 
     assetGrid.setStateful(false); 
     assetGrid.setLoadMask(true); 
     assetGrid.setStripeRows(true); 
     assetGrid.getView().setAutoFill(true); 
     assetGrid.getView().setEmptyText(MSGS.assetTableEmptyText()); 
     assetGrid.disableTextSelection(false); 

在我的刷新方法在这个类我只是做assetGrid.getStore()getLoader()负载(); 这就是它,但与TreeGrid我不能这样做。这是我TreeGrid的方法:

AsyncCallback<List<GwtTopic>> topicsCallback = new AsyncCallback<List<GwtTopic>>() { 

      @Override 
      public void onSuccess(List<GwtTopic> topics) { 
       store.add(topics, true); 
       topicInfoGrid.unmask(); 
      } 

      @Override 
      public void onFailure(Throwable t) { 
       FailureHandler.handle(t); 
       topicInfoGrid.unmask(); 
      } 
     }; 
     dataService.findTopicsTree(currentSession.getSelectedAccount().getId(), topicsCallback); 
     topicInfoGrid = new TreeGrid<GwtTopic>(store, new ColumnModel(configs)); 
     topicInfoGrid.setBorders(false); 
     topicInfoGrid.setStateful(false); 
     topicInfoGrid.setLoadMask(true); 
     topicInfoGrid.mask("Loading"); 
     topicInfoGrid.setStripeRows(true); 
     topicInfoGrid.getView().setAutoFill(true); 
     topicInfoGrid.getView().setEmptyText(MSGS.topicInfoGridEmptyText()); 
     topicInfoGrid.disableTextSelection(false); 

所以我的问题是如何使TreeGrid的刷新方法,就像我用常规网格完成。

回答

0

尝试添加此之后的onSuccess方法:

topicInfoGrid.getTreeView().refresh(true); 

或此,如果刷新不起作用

topicInfoGrid.reconfigure(store, cm, treeColumn);