Next/previous object

0
I have a listview from which a user can go to a detail page for each object. I would like to add two buttons -next and previous- so that the user can view the next or previous object from the listview without having to navigate back to the overview page. I figured I could retrieve a list of the objects and find the index of the current object, and show the same page for 'Index of current object +1' but I can't seem to find a good way of doing this. Ideas?
asked
3 answers
6

Does your listview have an attribute it's sorted on?

If so, you could use that same attribute in a retrieve action.

For example, if you have an Order object with an attribute OrderId, you could do a retrieve with an xPath constraint

Set the sorting to OrderId, and select Range: First, so you only retrieve 1 object instead of a list.

Now you will get the first Order that has an orderId greater then the OrderId of your current Order: i.e. the 'next' order.

For the previous object you could use the same logic, but use < and set sorting to Descending.

But be carefull with using this on an editable page, as it might not be clear to the user that his changes might (not) be saved.

answered
7

Also easy way is to use the listview and pagination widget. Set your listiview page size to 1

 

live demo here: https://paginationapp.mxapps.io/

 

answered
3

Should be possible as follows:

  1. Retrieve from database 
  2. Range: first
  3. XPath: index is < or > then currentobject/Index
  4. Sort on index ascending/descending (depending on next or previous)
answered