0

在 GXT 中是一个例子:
http ://www.sencha.com/examples/#ExamplePlace:paginggrid 我在哪里可以看到这个方法的实现:

service.getPosts(loadConfig, callback);

或任何其他类似服务

4

1 回答 1

1

例如,这里 -

http://spring-rapid.googlecode.com/svn/trunk/atom-explorer/src/main/java/com/atom/ebank/wfront/examples/resources/server/ExampleServiceImpl.java

...
    @Override
    public PagingLoadResult<Post> getPosts(PagingLoadConfig config) {
        if (posts == null) {
            loadPosts();
        }

        if (config.getSortInfo().size() > 0) {
            SortInfo sort = config.getSortInfo().get(0);
            if (sort.getSortField() != null) {
                final String sortField = sort.getSortField();
                if (sortField != null) {
                    Collections.sort(posts, sort.getSortDir().comparator(new Comparator<Post>() {
                        public int compare(Post p1, Post p2) {
                            if (sortField.equals("forum")) {
                                return p1.getForum().compareTo(p2.getForum());
                            } else if (sortField.equals("username")) {
                                return p1.getUsername().compareTo(p2.getUsername());
                            } else if (sortField.equals("subject")) {
                                return p1.getSubject().compareTo(p2.getSubject());
                            } else if (sortField.equals("date")) {
                                return p1.getDate().compareTo(p2.getDate());
                            }
                            return 0;
                        }
                    }));
                }
            }
        }

        ArrayList<Post> sublist = new ArrayList<Post>();
        int start = config.getOffset();
        int limit = posts.size();
        if (config.getLimit() > 0) {
            limit = Math.min(start + config.getLimit(), limit);
        }
        for (int i = config.getOffset(); i < limit; i++) {
            sublist.add(posts.get(i));
        }
        return new PagingLoadResultBean<Post>(sublist, posts.size(), config.getOffset());
    }
...
于 2013-07-23T18:11:40.650 回答