我正在開發一個應用程序,其中有用於編輯帳戶的編輯按鈕。當我編輯帳戶時,網格應該更新爲新的信息。但是,在我進入其他觀點後我會回來。但是我想在編輯表單中用戶點擊提交按鈕後立即看到更新的信息。所以,我無法找到刷新我的網格的方式。我GOOGLE了它,但沒有什麼是有用的(如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);
}
}
是否有人有想法如何刷新我的網格,當用戶點擊提交?