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
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | services-62773.patch | 2.42 KB | skyredwang |
| #2 | 674118.patch | 1.78 KB | skyredwang |
Comments
Comment #1
skyredwangSo, 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
Comment #2
skyredwangI 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.
Comment #3
skyredwangComment #5
skyredwangresubmit the patch with correct CVS folder information
Comment #6
skyredwangcommitted. http://drupal.org/cvs?commit=392670