How to reload data rows in a GXT grid?

Assuming that the data is retrieved from the DataStore using RPCproxy, it is populated into the grid using the ListStore when the page is opened.

Then a form appeared for adding an entity, and after modifying it, it will display a new list in the GXT grid with a new row added.

How to reload the grid? I tried using the .reconfigure () method in the Grid, but did not work.

+3
source share
2 answers

grid.getStore () getLoader () load (); ..

update:

First of all, you need to extract the Grid before your proxy, and the second is to change the RPC callback:

 
    public class PagingBeanModelGridExample extends LayoutContainer {  

    //put grid Class outside a method or declare it as a final on the begin of a method
    Grid grid = null;

    protected void onRender(Element parent, int index) {
        super.onRender(parent, index);

        RpcProxy> proxy = new RpcProxy>() {

            @Override
            public void load(Object loadConfig, final AsyncCallback> callback) {
                //modification here - look that callback is overriden not passed through!!
                service.getBeanPosts((PagingLoadConfig) loadConfig, new AsyncCallback>() {

                    public void onFailure(Throwable caught) {
                        callback.onFailure(caught);
                    }

                    public void onSuccess(PagingLoadResult result) {
                        callback.onSuccess(result);
                        //here you are reloading store
                        grid.getStore().getLoader().load();
                    }
                });
            }
        };

        // loader  
        final BasePagingLoader> loader = new BasePagingLoader>(proxy, new BeanModelReader());

        ListStore store = new ListStore(loader);
        List columns = new ArrayList();
        //...  
        ColumnModel cm = new ColumnModel(columns);

        grid = new Grid(store, cm);
        add(grid);

    }
} 
+3
source

, ? ListStore.

, CommentModel, BaseModel ListStore Comment Comment.

final ListStore<Commentmodel> commentStore = new ListStore<Commentmodel>();

//now call a rpc to load all available comments and add this to the commentStore.
commentService.getAllComment(new AsyncCallback<List<Commentmodel>>() {

   @Override
   public void onFailure(Throwable caught) {
    lbError.setText("data loading failure");

   }

   @Override
   public void onSuccess(List<Commentmodel> result) {
    commentStore.add(result);

   }
  }); 

commentService AsyncService.

, , CommentModel

CommentModel newData = new CommentModel('user name', 'message','date');

.

commentStore.add(newData);

, .

, . onSuccess , . , , .

+1

Source: https://habr.com/ru/post/1790906/


All Articles