Greetings,
I have an application which connects to a Drupal site via the JSON service. This application displays results from a view that contains roughly 700+ items. Rather than retrieve every single result, I'd like to only retrieve around 20 and implement a pager. My attempts to do this thus far have failed and I could really use some guidance :)

I noticed that there is a limit and offset argument that the documentation says is used for paging. The documentation also states that only 1 or the other can be used. What I don't understand is how you can implement paging without using both. If I wanted a 20 entry pager I'd want my limit to be 20 and my offset to be Current_Page * Limit, right?

Also, how can I retrieve the count of items in the view without actually getting them? Without this final count, it'd be impossible to create a pager that shows page numbers etc.

Any guidance would be highly appreciated!

-Shaun

CommentFileSizeAuthor
#5 services-62773.patch2.42 KBskyredwang
#2 674118.patch1.78 KBskyredwang

Comments

skyredwang’s picture

Status: Active » Closed (fixed)

So, you create a pager on your client side, and keep track of how many items you have received.
To get the first 20 items, you send Limit=20, Offset=0 to views.get
second 20 items, you send Limit=20, Offset=20
third 20 items, you send Limit=20, Offset=40
...
...
...
"n"th 20 items, you send Limit=20, Offset=20*n

skyredwang’s picture

Category: support » bug
StatusFileSize
new1.78 KB

I looked at the code today. I noticed one comment saying "If offset is set we can't have a user pager". I don't think that make sense unless I am missing something.

I have created a patch to fix it, so it works as my comment #1.

skyredwang’s picture

Status: Closed (fixed) » Needs review

Status: Needs review » Needs work

The last submitted patch, 674118.patch, failed testing.

skyredwang’s picture

Status: Needs work » Needs review
StatusFileSize
new2.42 KB

resubmit the patch with correct CVS folder information

skyredwang’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.