itpragmatik
24 Nov 2009, 9:39 PM
Hello,
I am a new user of GXT 2.0.1. I have been so far successful rendering a grid with some data (that gets fetched from database) using RPC.
public void ShowUserGrid() {
AsyncCallback callback = new AsyncCallback() {
public void onFailure(Throwable caught) {
// does some UI stuff to show failure
}
public void onSuccess(Object result) {
List<UserImpl> userList = (List<UserImpl>) result;
//Now that we have all the users fetched from database, show those in the grid
ContentPanel cp = new ContentPanel();
cp.setBodyBorder(false);
cp.setButtonAlign(HorizontalAlignment.CENTER);
cp.setLayout(new FitLayout());
ListStore<UserImpl> store = new ListStore<UserImpl>();
store.add(userList);
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("firstName");
column.setWidth(150);
column.setHeader("First Name");
configs.add(column);
column = new ColumnConfig();
column.setId("lastName");
column.setHeader("Last Name");
column.setWidth(100);
configs.add(column);
column = new ColumnConfig();
column.setId("emailAddress");
column.setHeader("Email");
column.setAlignment(HorizontalAlignment.RIGHT);
column.setWidth(150);
configs.add(column);
column = new ColumnConfig();
column.setId("id");
column.setHeader("Id");
column.setAlignment(HorizontalAlignment.LEFT);
column.setWidth(25);
configs.add(column);
ColumnModel cm = new ColumnModel(configs);
Grid<UserImpl> grid = new Grid<UserImpl>(store, cm);
grid.setStyleAttribute("borderTop", "none");
grid.setAutoExpandColumn("emailAddress");
grid.setAutoHeight(true);
grid.setBorders(true);
grid.setStripeRows(true);
grid.getView().setForceFit(true);
cp.add(grid);
cp.setIcon(ICONS.table());
cp.setHeading("Users");
cp.layout(true);
}
};
myservice.getAllUsers(callback);
}
Note that UserImpl extends BaseModel. All of the above works beautifully and I get a grid with desired number of rows for users and their associated information.
Now I want to add pagination to this grid. How do I do it?
I tried looking at the code in samples PagingGridExample.java but am little baffled by RpcProxy, PagingLoader, PagingLoadConfig etc and how they relate, sequence of execution etc. If I want to model my above code on same line as PagingGridExample, what refactoring or redesign would I have to do? Maybe if PagingGridExample was documented more, I would have got my answer.
Looking for help. Thanks.
I am a new user of GXT 2.0.1. I have been so far successful rendering a grid with some data (that gets fetched from database) using RPC.
public void ShowUserGrid() {
AsyncCallback callback = new AsyncCallback() {
public void onFailure(Throwable caught) {
// does some UI stuff to show failure
}
public void onSuccess(Object result) {
List<UserImpl> userList = (List<UserImpl>) result;
//Now that we have all the users fetched from database, show those in the grid
ContentPanel cp = new ContentPanel();
cp.setBodyBorder(false);
cp.setButtonAlign(HorizontalAlignment.CENTER);
cp.setLayout(new FitLayout());
ListStore<UserImpl> store = new ListStore<UserImpl>();
store.add(userList);
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("firstName");
column.setWidth(150);
column.setHeader("First Name");
configs.add(column);
column = new ColumnConfig();
column.setId("lastName");
column.setHeader("Last Name");
column.setWidth(100);
configs.add(column);
column = new ColumnConfig();
column.setId("emailAddress");
column.setHeader("Email");
column.setAlignment(HorizontalAlignment.RIGHT);
column.setWidth(150);
configs.add(column);
column = new ColumnConfig();
column.setId("id");
column.setHeader("Id");
column.setAlignment(HorizontalAlignment.LEFT);
column.setWidth(25);
configs.add(column);
ColumnModel cm = new ColumnModel(configs);
Grid<UserImpl> grid = new Grid<UserImpl>(store, cm);
grid.setStyleAttribute("borderTop", "none");
grid.setAutoExpandColumn("emailAddress");
grid.setAutoHeight(true);
grid.setBorders(true);
grid.setStripeRows(true);
grid.getView().setForceFit(true);
cp.add(grid);
cp.setIcon(ICONS.table());
cp.setHeading("Users");
cp.layout(true);
}
};
myservice.getAllUsers(callback);
}
Note that UserImpl extends BaseModel. All of the above works beautifully and I get a grid with desired number of rows for users and their associated information.
Now I want to add pagination to this grid. How do I do it?
I tried looking at the code in samples PagingGridExample.java but am little baffled by RpcProxy, PagingLoader, PagingLoadConfig etc and how they relate, sequence of execution etc. If I want to model my above code on same line as PagingGridExample, what refactoring or redesign would I have to do? Maybe if PagingGridExample was documented more, I would have got my answer.
Looking for help. Thanks.