Gravatar for

Question by Simon, Jul 25, 2014 2:39 PM

Pager update when changing the result per page.

Using the following code to show the maximum number of pages:

div class="CoveoPager pagination" data-number-of-pages="10"

If I use a custom control (radio button or dropdown) to allow my users to select the results returned per pages, how do I make sure that the pager gets adjusted?

So for example, I have two pages with 50 results on each. If the user chooses 100, I want the pager to show only one page, not two.


1 Reply
Gravatar for

Answer by Martin Laporte, Jul 28, 2014 10:05 AM

The value from the attribute is only read at initialization time, and even though it's sometimes possible to directly change the options afterwards by accessing the component directly, it's not officially supported to do so. In this particular case, the internal implementation takes a copy of the option value so you cannot change it once the UI is initialized.

Hence, the best way to achieve the result you're looking for would be to arrange for the user value to be put in the attribute before the UI is initialized (using server side code or JS code before 'init'). When a user changes his preference, you should reload the page in the browser.

Gravatar for

Comment by aga, Sep 12, 2016 1:26 PM

Hi, i see that this is fairly old post, but is this still the case? If we need to change the # of items on a page, do we need to reload the page with the updated data-number-of-pages value?

Gravatar for

Comment by Martin Laporte, Sep 13, 2016 5:39 AM

This probably hasn't changed BUT I know that an OOTB component to manage the number of results per page was added recently:

Not sure if it's part of an official release yet, and even then once the Search UI team makes a release in NPM it might take some more time for it to appear in an official Coveo for Sitecore or Salesforce release. But it'll get there at some point :)

Ask a question