我正在使用simplepager类为单元格表添加分页,它是第一次显示值,而我试图查看下一页结果它没有显示任何内容.... 我的代码是:
SimplePager pager;
SimplePager.Resources pagerResources=GWT.create(SimplePager.Resources.class);
pager=new SimplePager(TextLocation.CENTER, pagerResources, true, 0,true);
List<UserPage> userDetails=Arrays.asList(new UserPage("karthik",100.0,"SE"),
new UserPage("suresh",200.0,"SE"),
new UserPage("Srinivas",300.0,"SE"),
new UserPage("Bhaskar",400.0,""),
new UserPage("karthik",100.0,"SE"),
new UserPage("suresh",200.0,"SE"),
new UserPage("Srinivas",300.0,"SE"),
new UserPage("Bhaskar",400.0,""),
new UserPage("karthik",100.0,"SE"),
new UserPage("suresh",200.0,"SE"),
new UserPage("Srinivas",300.0,"SE"),
new UserPage("Bhaskar",400.0,null));
ListHandler<UserPage> sortHandler=new ListHandler<UserPage>(userDetails);
HTML content=new HTML("Welcome Admin");
CellTable<UserPage> table=new CellTable<UserPage>();
pager.setDisplay(table);
pager.setPageSize(3);
EditTextCell nameCell=new EditTextCell();
Column<UserPage, String> nameColumn=new Column<UserPage, String>(nameCell) {
@Override
public String getValue(UserPage object) {
// TODO Auto-generated method stub
return object.getUserName();
}
};
table.addColumn(nameColumn,"UserName");
EditTextCell userIdCell=new EditTextCell();
Column<UserPage, String> userIdColumn=new Column<UserPage, String>(userIdCell) {
@Override
public String getValue(UserPage object) {
// TODO Auto-generated method stub
return (object.getUserId()).toString();
}
};
table.addColumn(userIdColumn, "UserID");
EditTextCell desgCell=new EditTextCell();
Column<UserPage, String> desgColumn=new Column<UserPage, String>(desgCell) {
@Override
public String getValue(UserPage object) {
// TODO Auto-generated method stub
return object.getDesignation();
}
};
table.addColumn(desgColumn,"Designtion");
//table.setPageSize(userDetails.size());
table.setRowCount(4,false);
table.setRowData(0,userDetails);
table.addColumnSortHandler(sortHandler);
adminPage.add(content);
adminPage.add(table);
adminPage.add(pager);
让我知道我的代码有什么问题..... 提前谢谢....
答案 0 :(得分:2)
我将我的代码更改为:
ListDataProvider<UserPage> dataProvider=new ListDataProvider<UserPage>();
dataProvider.addDataDisplay(table);
dataProvider.setDataDisplay(userDetails);
它现在正在运作....