Question

I am working on gwt and there is a case in whch when i click a button the exixting grid from the panel should be removed and a new grid should be added. Can some one please help me on this. Below is my code which is executed when i click on refresh button. I am editing the existing grid and updating few details in the data base. So when i click on this refresh button i was again making a new rpc call and fetching the new data after updating the grid and i need to dispaly the new data in the existing grid itself.

            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);

I was able to remove the old grid but when add the new grid to the panel it is not displaying the new data.

Below is the picture

![enter image description here][1]

Thanks in advance.

Was it helpful?

Solution

I assume, you are using GXT. ContentPanel, FitLayout, EditorGrid are classes which come with Sencha GXT, I think version 2.x. Check if you have import which starts with "com.extjs".

You have a problem with your layout chain. Are you using a FlowLayout in one of the parent panels?

Have you tried to call forceLayout() or

panel.getLayout().layout();

after adding the new Grid?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top