To display the new data to grid do you really need to reload the grid?
You can create a new model object with the new data and add this to the ListStore.
Suppose you have a CommentModel which extends the BaseModel and a ListStore of Comment model commentStore.
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
is an AsyncService
.
Now if a user post a comment, just create a new CommentModel
object with the new data
CommentModel newData = new CommentModel('user name', 'message','date');
And add this to the commentStore.
commentStore.add(newData);
Hope this will serve you purpose.
But if you really need to reload the whole set of data, call the service again. In the onSuccess
method first clear the commentStore then add result. Remember this is more more time consuming that the 1st approach.