How do I bind a pagination element to a passed collection param inside a component?

I went digging a little bit, and if you wanted to do this, you can and it’s actually pretty simple.

What you want to do is the following:

  1. Create your component, with your paginator, it has to be set to Custom Pagination
  2. Create a variable of type Collection (collection_id) on that component
  3. Add an On change event onto your pagination element, by using the details from the event, you can use this method in a Custom JavaScript Action (this method is what WeWeb uses to do the same with the paginator):
wwLib.wwCollection.setOffset([your_colleciton_id_variable_here], [event.index] * [event.offset]);
// This wwLib method takes two arguments, setOffset(collection_id <uuid>, offset <integer> )

The offset is basically how many items you want to have, so lets say you want to have three items per page, for a page two, this would be six items (2*3). I’ve tested it and it actually works.

1 Like