我正在开发一个应用程序,其中有用于编辑帐户的“编辑”按钮。当我编辑帐户时,应使用新信息更新网格。但这发生在我继续其他看法之后又回来了。但是我想在用户单击编辑表单中的“提交”按钮后立即看到更新的信息。因此,我找不到刷新网格的方法。我用谷歌搜索,但没有任何帮助(例如grid.getView.refresh等)。这是我的课程,在getToolbar方法中,是当用户单击“提交”按钮时应该完成的逻辑:
@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);
}
}
当用户单击“提交”时,有人知道如何刷新网格吗?
最佳答案
您需要提交对模型的更改:
store.commitChanges();