jmesa数据库物理分页

TableModel tableModel = new TableModel("userlist", req);

		tableModel.setItems(new PageItems() {

			public int getTotalRows(Limit limit) {
				return userService.countAll();
			}

			public Collection<?> getItems(Limit limit) {
				int start = limit.getRowSelect().getRowStart();
				int end = limit.getRowSelect().getRowEnd();
				FilterSet fs = limit.getFilterSet();
				for (Filter f : fs.getFilters()) {
					//如果需要条件过滤的话可以这样去的过滤条件
					System.out.println(f.getProperty() + "=" + f.getValue());
				}

				return userService.getPage(start, end);
			}
		});
		tableModel.setTable(getTable());

private HtmlTable getTable() {
		HtmlTable htmlTable = new HtmlTable().caption("User List").width("600px");

		HtmlRow htmlRow = new HtmlRow();
		htmlTable.setRow(htmlRow);

		HtmlColumn id = new HtmlColumn("id");
		htmlRow.addColumn(id);

		HtmlColumn name = new HtmlColumn("name");
		htmlRow.addColumn(name);

		HtmlColumn password = new HtmlColumn("password");
		htmlRow.addColumn(password);

		HtmlColumn sex = new HtmlColumn("sex");
		htmlRow.addColumn(sex);

		HtmlColumn delete = new HtmlColumn("delete");
		delete.setCellEditor(new CellEditor() {
			public Object getValue(Object item, String property, int rowcount) {
				User u = (User) item;
				HtmlBuilder builder = new HtmlBuilder();
				String js = "javascript:void(0);";
				builder.a().href(js).close();
				builder.append("删除");
				builder.aEnd();
				return builder.toString();
			}
		});
		htmlRow.addColumn(delete);

		htmlRow.setUniqueProperty("id");

		return htmlTable;
	}

你可能感兴趣的:(JavaScript,F#)