2017-08-28 12 views
1

私は、アカウントを編集するための編集ボタンを持っているアプリケーションを開発しています。そして私がアカウントを編集するとき、グリッドは新しい情報で更新されるべきです。しかし、それは私が別の視点をとった後に起こり、その後私は戻ってくる。しかし、ユーザーが編集フォームでボタンをクリックした直後に、その情報が更新されたことを確認したい。だから、私はグリッドをリフレッシュする方法を見つけることができません。私はそれをgoogledが何も役立たなかった(grid.getView.refreshなど)。これは私のクラスであるとGetToolbar関数法では、ユーザーが送信ボタンをクリックしたときに行われるべきロジックです:GWTで更新後にグリッドをリフレッシュする方法は?

@Override 
    protected void onRender(Element parent, int index) { 
     super.onRender(parent, index); 
     setLayout(new FitLayout()); 
     setBorders(false); 
     initTable(); 

    } 

    protected void initTable() { 
     getToolBar(); 
     initGrid(); 

     tableContainer = new ContentPanel(); 
     tableContainer.setBorders(false); 
     tableContainer.setBodyBorder(false); 
     tableContainer.setHeaderVisible(false); 
     tableContainer.setTopComponent(accountsToolBar); 
     tableContainer.setScrollMode(Scroll.AUTO);  
     tableContainer.setLayout(new FitLayout()); 
     tableContainer.add(grid); 
     add(tableContainer); 

    } 

    private void initGrid() { 
     RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() { 

      @Override 
      protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) { 
       gwtAccountService.getAccountInfo(selectedAccount.getId(), callback); 
      } 
     }; 

     loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy); 
     loader.addLoadListener(new DataLoadListener()); 

     store = new GroupingStore<GwtGroupedNVPair>(loader); 
     store.groupBy("groupLoc"); 

     ColumnConfig name = new ColumnConfig("nameLoc", MSGS.devicePropName(), 50); 
     ColumnConfig value = new ColumnConfig("value", MSGS.devicePropValue(), 50); 

     List<ColumnConfig> config = new ArrayList<ColumnConfig>(); 
     config.add(name); 
     config.add(value); 

     ColumnModel cm = new ColumnModel(config); 
     GroupingView view = new GroupingView(); 
     view.setShowGroupedColumn(false); 
     view.setForceFit(true); 
     view.setEmptyText(MSGS.accountNoSelectedAccount()); 

     grid = new Grid<GwtGroupedNVPair>(store, cm); 
     grid.setView(view); 
     grid.setBorders(false); 
     grid.setLoadMask(true); 
     grid.setStripeRows(true); 
     grid.setTrackMouseOver(false); 
     grid.disableTextSelection(false); 
     updateAccountInfo(); 
     add(grid); 
    } 

    protected void updateAccountInfo() { 
     if (store != null) { 
      store.removeAll(); 
      loader.load(); 
     } 
    } 

    private ToolBar getsToolBar() { 

     accountsToolBar = new ToolBar(); 
     accountsToolBar.setHeight("27px"); 
     if (currentSession.hasAccountUpdatePermission()) { 
      // 
      // Edit Account Button 
      editButton = new EditButton(new SelectionListener<ButtonEvent>() { 

       @Override 
       public void componentSelected(ButtonEvent ce) { 
        if (selectedAccount != null) { 
         final AccountForm accountForm = new AccountForm(currentSession, selectedAccount); 
         accountForm.addListener(Events.Hide, new Listener<ComponentEvent>() { 

          public void handleEvent(ComponentEvent be) { 


           setAccount(accountForm.getExistingAccount()); 
           refresh(); 

          } 
         }); 
         accountForm.show(); 
        } 
       } 
      }); 
      editButton.setEnabled(true); 

      accountsToolBar.add(editButton); 
      accountsToolBar.add(new SeparatorToolItem()); 
     } 
     return accountsToolBar; 
    } 

    public void refresh() { 
     if (initialized && dirty && selectedAccount != null) { 
      updateAccountInfo(); 
      dirty = false; 
     } 
     if (selectedAccount != null) { 
      if (formPanel != null) { 
       formPanel.show(); 
      } 
      editButton.setEnabled(true); 
     } else { 
      if (formPanel != null) { 
       formPanel.hide(); 
      } 
      editButton.setEnabled(false); 
     } 

    } 

誰かが、ユーザが提出をクリックしたとき、私のグリッドをリフレッシュする方法のアイデアを持っていますか?

答えて

0

あなたは、モデルに変更をコミットする必要があります。

store.commitChanges(); 
0

あなたストアが、その後変更されることがわかっている場合は試してみてください。

grid.getView().refresh(true); 
関連する問題