我正在研究gwt,有一种情况,当我点击一个按钮时,应该删除面板上的exixting网格,并添加一个新的网格。有人可以帮我这个。下面是我点击刷新按钮时执行的代码。我正在编辑现有网格并更新数据库中的一些细节。因此,当我点击此刷新按钮时,我再次进行新的rpc调用并在更新网格后获取新数据,我需要显示现有网格本身中的新数据。
RpcProxy< String> proxy_refresh = new RpcProxy< String>() {
protected void load(Object loadConfig, AsyncCallback<String> callback) {
if (itemService == null) {
itemService = GWT.create(ReleaseItemService.class);
}
itemService.search(criteria, callback);
}
};
xml.setRoot("resultset");
xml.setRecordName("record");
xml.addField("release_id");
xml.addField("project_name");
xml.addField("type");
xml.addField("business_unit");
xml.addField("project_manager");
xml.addField("developer");
xml.addField("deployer");
xml.addField("verifier");
xml.addField("status");
xml.addField("item_no");
xml.addField("qa_developer");
xml.addField("deployment_date");
XmlReader reader_refresh = new XmlReader(xml);
BaseListLoader loader_refresh = new BaseListLoader(proxy_refresh, reader_refresh);
loader_refresh.addLoadListener(new LoadListener() {
public void loaderLoadException(LoadEvent le) {
super.loaderLoadException(le);
MessageBox.alert("Error", le.exception.getMessage(), null);
}
});
columns = new ArrayList<ColumnConfig>(6);
columns.add(new ColumnConfig("release_id", "Release ID", 70));
columns.add(new ColumnConfig("item_no", "Item No", 70));
columns.add(new ColumnConfig("deployment_date", "Deployment Date", 150));
columns.add(new ColumnConfig("business_unit", "Business Unit", 100));
columns.add(new ColumnConfig("type", "Type", 120));
columns.add(new ColumnConfig("project_name", "Project Name", 120));
columns.add(new ColumnConfig("status", "Status", 100));
columns.add(new ColumnConfig("developer", "Devloper", 100));
columns.add(new ColumnConfig("qa_deployer", "QA Deployer", 125));
store_refresh = new ListStore<BaseModelData>(loader_refresh);
ColumnModel columnModel1 = new ColumnModel(columns);
System.out.println("removing grid from panel");
grid.removeFromParent();
if(flag==true){
System.out.println("Removing grid1");
grid1.removeFromParent();
}
// grid1.removeFromParent();
System.out.println("Creating new grid");
grid1 = new EditorGrid(store_refresh, columnModel1);
grid1.setBorders(true);
grid1.setAutoHeight(true);
grid1.setLoadMask(true);
grid1.setStripeRows(true);
grid1.getView().setEmptyText("No data found for the given criteria");
System.out.println("Adding grid1 to panel");
loader_refresh.load();
grid1.getStore().getLoader().load();
panel.add(grid1);
panel.getLayout().layout();
//submit.hide();
loader_refresh.load();
flag = true;
System.out.println("Loader refresh "+loader_refresh.load()+" store refresh is "+store_refresh.getCount());
proxy_refresh = null;
store_refresh = null;
loader_refresh = null;
reader_refresh = null;
System.out.println("Loader refresh "+loader_refresh+" store refresh is "+store_refresh+"proxy_refresh "+proxy_refresh+"reader_refresh "+reader_refresh);
我能够移除旧网格,但是当将新网格添加到面板时,它不会显示新数据。
下面是图片
![在此处输入图片说明] [1]
提前致谢。
答案 0 :(得分:0)
我假设你正在使用GXT。 ContentPanel,FitLayout,EditorGrid是Sencha GXT附带的类,我认为版本2.x.检查您是否具有以“com.extjs”开头的导入。
您的布局链存在问题。您是否在其中一个父面板中使用FlowLayout?
您是否尝试过调用forceLayout()或
panel.getLayout().layout();
添加新网格后?