Pagination
TsgcHTMLComponent_Pagination — 渲染一个页面导航控件,带有上一页/下一页、首页/末页和一个滑动的页码窗口,适用于 Delphi、C++ Builder 和 .NET。
TsgcHTMLComponent_Pagination — 渲染一个页面导航控件,带有上一页/下一页、首页/末页和一个滑动的页码窗口,适用于 Delphi、C++ Builder 和 .NET。
一个导航组件,发出 Bootstrap <ul class="pagination">。为其提供当前页和总页数(或总项目数和每页条数)以及一个基础 URL,然后读取 HTML 属性。
设置 CurrentPage 和 TotalPages(或 TotalItems + PageSize)以及 BaseURL,然后读取 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">
您最常使用的成员。
CurrentPage 和 TotalPages 直接驱动控件;或设置 TotalItems 和 PageSize,总数会自动为您计算。
BaseURL(默认 ?page=)是每个页面链接指向的前缀,并附加页码。
MaxVisible(默认 5)限制显示多少个编号链接,围绕 CurrentPage 滑动。
ShowPrevNext(默认 True)添加上一页/下一页;ShowFirstLast 添加首页/末页;两者在范围两端均禁用。
Size 选择 psDefault、psSmall 或 psLarge;Align 选择 paStart、paCenter(默认)或 paEnd;PaginationID 设置 id。
HTML 返回带有分页列表的 <nav>(只有单页时为空)— 直接提供服务,或将其赋给页面模板的 BodyContent。