Skip to content

Pagination Examples

Basic Pagination

Enable infinite-scroll pagination for AJAX results:

When the user scrolls to the bottom of the dropdown, DotSelect automatically loads the next page.

Expected API Response

json
{
  "data": [
    { "id": 1, "text": "Alice" },
    { "id": 2, "text": "Bob" },
    { "id": 3, "text": "Carol" }
  ],
  "pagination": {
    "more": true
  }
}

When pagination.more is false, DotSelect stops loading more pages.

Custom Page Size

Load more results per page to reduce the number of requests:

Custom "Has More" Key

If your API uses a different key for the "has more pages" flag:

Expected response:

json
{
  "data": [
    { "id": 1, "text": "Item 1" },
    { "id": 2, "text": "Item 2" }
  ],
  "meta": {
    "has_next_page": true,
    "current_page": 1,
    "total_pages": 5
  }
}

Pagination with Templates

Combine pagination with custom templates:

Pagination with Multiple Select

Paginated results with multi-select and exclusion of selected items:

Pagination with Virtual Scroll

For the best performance with large paginated datasets, combine with the virtual-scroll plugin:

TIP

When using virtual scroll with pagination, consider using a larger data-pagination-limit (e.g., 100) to reduce the number of network requests, since virtual scroll handles the rendering performance.

Custom Load More Text

Override the "Load more" text at the bottom of the dropdown:

MIT Licensed