java - How to add data to the GXT Grid properly? -


i have webapp in need data file , fill table. here code of page table:

public class rules extends contentpanel{     private final servermanagementasync servermanagementsvc = gwt.create(servermanagement.class);     private arraylist<propertyitem> propslist;     private arraylist<propertyitem> itemarraylist;     private editorgrid<propertyitem> grid;      public rules(final string customerid){         setlayout(new flowlayout(10));          list<columnconfig> configs = new arraylist<columnconfig>();          columnconfig column = new columnconfig();         column.setid("name");         column.setheader("name");         column.setwidth(220);          textfield<string> text = new textfield<string>();         text.setallowblank(false);         column.seteditor(new celleditor(text));         configs.add(column);          column = new columnconfig();         column.setid("type");         column.setheader("type");         column.setwidth(220);          textfield<string> typetext = new textfield<string>();         typetext.setallowblank(false);         column.seteditor(new celleditor(typetext));         configs.add(column);          column = new columnconfig();         column.setid("value");         column.setheader("value");         column.setwidth(220);         configs.add(column);          final liststore<propertyitem> store = new liststore<propertyitem>();         propslist = getpropslist(customerid);          (propertyitem propertyitem: propslist){             store.insert(propertyitem, 0);         }          columnmodel cm = new columnmodel(configs);          setheading("settings");         setframe(true);         setwidth(600);         setlayout(new fitlayout());          grid = new editorgrid<propertyitem>(store, cm);         grid.setautoexpandcolumn("name");         grid.setborders(true);         add(grid);          toolbar toolbar = new toolbar();         settopcomponent(toolbar);         setbuttonalign(style.horizontalalignment.right);          addbutton(new button("refresh", new selectionlistener<buttonevent>() {             @override             public void componentselected(buttonevent ce) {                 store.insert(getpropslist(customerid), 5);             }         }));         addbutton(new button("add", new selectionlistener<buttonevent>() {              @override             public void componentselected(buttonevent ce) {                 store.commitchanges();             }         }));       }      public arraylist<propertyitem> getpropslist(string customerid){         itemarraylist = new arraylist<propertyitem>();         asynccallback<arraylist<propertyitem>> callback = new asynccallback<arraylist<propertyitem>>() {             @override             public void onfailure(throwable throwable) {              }              @override             public void onsuccess(arraylist<propertyitem> propertyitems) {                 itemarraylist = propertyitems;                 window.alert("read successful");                 }             }         };         servermanagementsvc.getproperties(customerid, callback);         return itemarraylist;     } } 

when run app see columns names , no data in cells(and no cells of course). example used one: ext gwt 2.2.6 explorer(grid)

i don't understand cause such proplem. can reason of this?

because propslist being populated asynchronously grid being rendered before server call returns.

to fix first make store private property grid

next, move code populates store:

    (propertyitem propertyitem: propslist){         store.insert(propertyitem, 0);     } 

into onsuccess method of callback.

lastly, may need call : grid.reconfigure(grid.getstore(), grid.getcolumnmodel()); grid render again.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -