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 — render a page-navigation control with prev/next, first/last and a sliding window of page numbers, in Delphi, C++ Builder and .NET.
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.
TsgcHTMLComponent_Pagination
Bootstrap pagination markup
Delphi, C++ Builder, .NET
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">
The members you reach for most often.
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.
MaxVisible (default 5) caps how many numbered links show, sliding around CurrentPage.
ShowPrevNext (default True) adds previous/next; ShowFirstLast adds first/last; both disable at the ends of the range.
Size picks psDefault, psSmall or psLarge; Align picks paStart, paCenter (default) or paEnd; PaginationID sets the id.
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.