question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hiding the pagination if there is only one page

See original GitHub issue

Is your feature request related to a problem? Please describe 🙏 I’d like to hide the pagination when there is only one page of results. In that context, the pagination only adds clutter without meaningful interaction.

Describe the solution you’d like 🤔 Ideally I think a custom way of auto-hiding the container of widgets could be useful. I saw it was discussed already, and I think it might be useful for more than this widget.

Maybe something like autoHideContainer(params), where params are the search result response?

Describe alternatives you’ve considered ✨

I could listen to the helper.on('result') and hide the pagination wrapper when only one page is returned and display it when several pages are returned. This seems a bit hackish, adding widget-related logic outside of the widget itself.

I also tried to use connectPagination to add the needed branching logic there, but custom connectors are completely independent from the default widgets and there is no way to make them fallback to the default rendering method AFAIK.

I saw an old issue that suggest overwriting the widget .render method with a wrapper function. I’m unsure if this is still doable (the issue is 2+ years old)

ccing @Haroenv @bobylito as we discussed this

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
francoischalifourcommented, Mar 14, 2019

You can now achieve this behavior with the panel widget in InstantSearch.js 3:

const pagination = instantsearch.widgets.panel({
  hidden: ({ results }) => results.nbPages === 1,
})(instantsearch.widgets.pagination);

search.addWidget(
  pagination({
    container: '#pagination',
  })
);
2reactions
francoischalifourcommented, Jul 27, 2020

@johnnybboiii In React InstantSearch you can rely on the ais-Pagination-noRefinement CSS class to hide the widget (see example).

Read more comments on GitHub >

github_iconTop Results From Across the Web

disable pagination if there is only one page in datatables
Building off of Nicola's answer, you can use the fnDrawCallback() callback and the oSettings object to hide the table pagination after it's ......
Read more >
Hide Pagination and Page Limits unless more than 1 page is ...
I was wondering, is there a way to have DT hide both of those, unless the minimum limit has been passed? Meaning if...
Read more >
Data tables pagination not needed when only one page #8516
With the DataTables plugin, when only one page of results is returned, the pagination should be hidden. It's confusing to see a big...
Read more >
Hide Pagination if one page results - Oracle APEX
Recently I made an observation regarding a handy new template option, one that hides pagination if there is only one page of records....
Read more >
[OutSystems Data Grid] Hide Pagination bar in DataGrid ...
[OutSystems Data Grid] Hide Pagination bar in DataGrid Reactive if there is only one page · 1) make a local integer variable to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found