Alex Rivera | Logout

Pagination in GWT

Asked 2010-12-11T18:03:28.860
9

Is pagination supported in GWT? Does GWT provide a GWT GUI element?

gwt
Edit
Report

2 Answers

6

I have tried pagination with Celltable and it goes fine.

In your activity, you should do something similar to this:

CellTable table;

@Override
public void start(AcceptsOneWidget panel, EventBus eventBus) {
    // Get the table from the view
    view.setPresenter(this);
    panel.setWidget(view.asWidget());
    table=view.getCellTable();
    final SingleSelectionModel<Your_Class> selectionModel = new SingleSelectionModel<Your_Class>();
    table.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
            public void onSelectionChange(SelectionChangeEvent event) {
                Your_Class selected = selectionModel.getSelectedObject();
                if (selected != null) {
                    // Go to edit screen with selected.getId(); 
                }
            }
        });
}

Then in your implementation view create the columns:

table = new CellTable<Your_Class>();
table.setSelectionModel( new SingleSelectionModel<Your_Class>());

And finally put the pagination:

SimplePager pager;
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
pager = new SimplePager(TextLocation.CENTER, pagerResources, true, 0,true);
pager.setDisplay(table);

dataProvider.setList(list_of_data);
pager.setPageSize(number_you_want);
answered 2012-09-26T09:05:10.487
4

yes.CellTable is really a good option for pagination.Once you get used to it.u will find it very user friendly.use simplePager for pagination.

answered 2011-12-20T09:21:18.153

Your Answer