Pagination

TsgcHTMLComponent_Pagination — render a page-navigation control with prev/next, first/last and a sliding window of page numbers, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_Pagination

A navigation component that emits a Bootstrap <ul class="pagination">. Give it the current and total pages (or total items and page size) plus a base URL, then read the HTML property.

Component class

TsgcHTMLComponent_Pagination

Renders

Bootstrap pagination markup

Languages

Delphi, C++ Builder, .NET

Create it, set the page state, render it

Set CurrentPage and TotalPages (or TotalItems + PageSize) and a BaseURL, then read HTML.

uses
  sgcHTML_Component_Pagination;

var
  oPagination: TsgcHTMLComponent_Pagination;
begin
  oPagination := TsgcHTMLComponent_Pagination.Create(nil);
  try
    oPagination.BaseURL := '/list?page=';
    oPagination.CurrentPage := 3;
    oPagination.TotalPages := 12;
    oPagination.MaxVisible := 5;
    oPagination.ShowFirstLast := True;
    oPagination.Align := paCenter;

    WebModule.Response := oPagination.HTML;   // <ul class="pagination">
  finally
    oPagination.Free;
  end;
end;
// includes: sgcHTML_Component_Pagination.hpp

TsgcHTMLComponent_Pagination *oPagination = new TsgcHTMLComponent_Pagination(NULL);
try
{
  oPagination->BaseURL = "/list?page=";
  oPagination->CurrentPage = 3;
  oPagination->TotalPages = 12;
  oPagination->MaxVisible = 5;
  oPagination->ShowFirstLast = true;
  oPagination->Align = paCenter;

  String html = oPagination->HTML;   // <ul class="pagination">
}
__finally
{
  delete oPagination;
}
using esegece.sgcWebSockets;

var pagination = new TsgcHTMLComponent_Pagination();
pagination.BaseURL = "/list?page=";
pagination.CurrentPage = 3;
pagination.TotalPages = 12;
pagination.MaxVisible = 5;
pagination.ShowFirstLast = true;
pagination.Align = TsgcHTMLPaginationAlign.paCenter;

string html = pagination.HTML;   // <ul class="pagination">

Key properties & methods

The members you reach for most often.

Page state

CurrentPage and TotalPages drive the control directly; or set TotalItems and PageSize and the total is computed for you.

BaseURL (default ?page=) is the prefix each page link points to, with the page number appended.

Window

MaxVisible (default 5) caps how many numbered links show, sliding around CurrentPage.

Edge buttons

ShowPrevNext (default True) adds previous/next; ShowFirstLast adds first/last; both disable at the ends of the range.

Appearance

Size picks psDefault, psSmall or psLarge; Align picks paStart, paCenter (default) or paEnd; PaginationID sets the id.

Output

HTML returns the <nav> with its pagination list (empty when there is a single page) — serve it, or assign it to a page template's BodyContent.

Keep exploring

All sgcHTML ComponentsBrowse the full feature matrix of 60+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and start building web UIs in Delphi, C++ Builder and .NET.