PDA

View Full Version : Grid Pagination toolbar not refreshing



vijay_v11
15 Aug 2010, 11:45 PM
Hi,

I am facing an issue with the pagination toolbar attached to a grid. Upon adding new rows to the grid, the pagination toolbar fails to update itself to reflect the new data and count. I have tried explicitly refreshing both the GridView as well as the toolbar. I am using GXT 2.1.1 version.

I have pasted the sample code below for your reference. There are 3 main components in the code: the grid, the pagination toolbar and a button which loads new data to the grid when clicked. Any solutions to this issue?.. Thanks in advance..






public class ADKWidgets implements EntryPoint {



private ADKWidgets() {


}


public void onModuleLoad() {


List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("forum", "Forum", 180));
columns.add(new ColumnConfig("subject", "Subject", 200));


ColumnModel cm = new ColumnModel(columns);



PagingLoader<PagingLoadResult<ModelData>> loader;
PagingModelMemoryProxy proxy = new PagingModelMemoryProxy(getPosts());
loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy);



PagingToolBar toolBar = new PagingToolBar(5) {
protectedvoid onLoad(LoadEvent event) {
super.onLoad(event);
if (activePage > pages) {


last();


}


}

};

toolBar.bind(loader);










ListStore<Post> store = new ListStore<Post>(loader);
store.getLoader().load();
store.setMonitorChanges(true);


final Grid<Post> grid = new Grid<Post>(store, cm);
GridView view = new GridView();
grid.setView(view);


final ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setCollapsible(true);


panel.setAnimCollapse(false);


panel.setHeading("Paging Grid");


panel.setLayout(new FitLayout());







Button reload = new Button();
reload.setText("Load New data");
reload.addListener(Events.Select, new SelectionListener<ButtonEvent>() {

@Override

publicvoid componentSelected(ButtonEvent ce) {


grid.getStore().add(getNewPosts());


grid.getView().refresh(false);


//PagingToolBar toolBar = (PagingToolBar) panel.getBottomComponent();


//toolBar.refresh();

}

});







panel.add(grid);

panel.setSize(600, 250);

panel.setTopComponent(reload);
panel.setBottomComponent(toolBar);










RootPanel.get().add(panel);
}


private List<Post> getPosts() {


List<Post> posts = new ArrayList<Post>();


posts.add(new Post("User1", "Jack", new Date(), "Mumbai", false));
posts.add(new Post("User2", "Roland", new Date(), "Paris", true));
posts.add(new Post("User3", "Eddie", new Date(), "London", false));


posts.add(new Post("User4", "Susahnna", new Date(), "Madrid", true));


posts.add(new Post("User5", "Walter", new Date(), "Vienna", true));


posts.add(new Post("User6", "Bob", new Date(), "Ohio", false));

posts.add(new Post("User7", "Cuthbert", new Date(), "Washington D.C", false));

posts.add(new Post("User8", "Yngwie", new Date(), "Iowa", true));
posts.add(new Post("User9", "Richard", new Date(), "Minnesota", false));
posts.add(new Post("User10", "Cort", new Date(), "Nebraska", true));
posts.add(new Post("User11", "Frank", new Date(), "Oklahoma", true));
posts.add(new Post("User12", "Doug", new Date(), "Pennsylvania", false));
posts.add(new Post("User13", "Mia", new Date(), "Texas", false));
posts.add(new Post("User14", "Elise", new Date(), "South Dakota", true));
posts.add(new Post("User15", "Raphael", new Date(), "Tennessee", false));












return posts;
}


private List<Post> getNewPosts() {


List<Post> posts = new ArrayList<Post>();


posts.add(new Post("User16", "Benoit", new Date(), "West Virginia", true));
posts.add(new Post("User17", "Nuno", new Date(), "Wisconsin", false));
posts.add(new Post("User18", "Smith", new Date(), "Hawaii", false));


posts.add(new Post("User19", "Paul", new Date(), "Connecticut", true));


posts.add(new Post("User20", "Mike", new Date(), "Arizona", true));




return posts;

}


class Post extends BaseModelData {


private static final long serialVersionUID = 1L;

public Post(String user, String forum, Date date, String subject, boolean intern) {


setUsername(user);


setForum(forum);


setDate(date);


setSubject(subject);


setIntern(intern);

}










public Post() {
}


public String getUsername() {


return (String) get("username");


}






public void setUsername(String username) {


set("username", username);


}






public String getForum() {


return (String) get("forum");


}






public void setForum(String forum) {


set("forum", forum);


}






public Date getDate() {


return get("date");


}






public void setDate(Date date) {


set("date", date);


}






public String getSubject() {


return (String) get("subject");


}







public void setSubject(String subject) {


set("subject", subject);


}






public boolean getIntern() {


return (Boolean) get("intern");


}






public void setIntern(boolean intern) {


set("intern", intern);


}







}

sven
16 Aug 2010, 1:32 AM
The pagingtoolbar gets its data from the loadconfig in the loadevent. Only the loadevent has this info. You need to manuallay update the pagingtoolbar.

Vinod Jayendra
16 Jun 2011, 7:57 PM
Hi Sven,

Can you please provide the sample code to manually update the pagingtoolbar.

Thanks