DataTable

TsgcHTMLComponent_DataTable — 一个更高级的数据表,将 Grid 和 Pagination 封装在卡片中,带有搜索工具栏、每页条数选择器、导出按钮和行数统计,适用于 Delphi、C++ Builder 和 .NET。

TsgcHTMLComponent_DataTable

绑定数据集,设置每页条数和工具栏选项,然后读取 HTML 属性 — 如果需要更精细的控制,会公开内部的 GridPagination

组件类

TsgcHTMLComponent_DataTable

渲染为

带有工具栏、<table> + 分页的 Bootstrap 5 卡片

语言

Delphi, C++ Builder, .NET

绑定数据集、设置工具栏、渲染它

设置 Title 和工具栏标志,用每页条数调用 LoadFromDataSet,然后读取 HTML。访问内部的 Grid 可调整列。

uses
  sgcHTML_Component_DataTable;

var
  oTable: TsgcHTMLComponent_DataTable;
begin
  oTable := TsgcHTMLComponent_DataTable.Create(nil);
  try
    oTable.Title := 'Customers';
    oTable.ShowSearch := True;
    oTable.ShowExport := True;
    oTable.ShowRowCount := True;
    oTable.SearchPlaceholder := 'Search customers...';

    oTable.Grid.Striped := True;
    oTable.LoadFromDataSet(qryCustomers, 25);

    WebModule.Response := oTable.HTML;   // card + table + pagination
  finally
    oTable.Free;
  end;
end;
// includes: sgcHTML_Component_DataTable.hpp

TsgcHTMLComponent_DataTable *oTable = new TsgcHTMLComponent_DataTable(NULL);
try
{
  oTable->Title = "Customers";
  oTable->ShowSearch = true;
  oTable->ShowExport = true;
  oTable->ShowRowCount = true;
  oTable->SearchPlaceholder = "Search customers...";

  oTable->Grid->Striped = true;
  oTable->LoadFromDataSet(qryCustomers, 25);

  String html = oTable->HTML;   // card + table + pagination
}
__finally
{
  delete oTable;
}
using esegece.sgcWebSockets;

var table = new TsgcHTMLComponent_DataTable();
table.Title = "Customers";
table.ShowSearch = true;
table.ShowExport = true;
table.ShowRowCount = true;
table.SearchPlaceholder = "Search customers...";

table.Grid.Striped = true;
table.LoadFromDataSet(qryCustomers, 25);

string html = table.HTML;   // card + table + pagination

关键属性与方法

您最常使用的成员。

数据集绑定

LoadFromDataSet(aDataSet, aPageSize) 填充内部网格并根据记录数设置分页;DataSource 驱动实时刷新。

工具栏

ShowSearch 配合 SearchPlaceholderSearchActionShowExportShowPageSize 配合 PageSizes,以及 Title 标题共同构成工具栏。

页脚

ShowRowCount 在卡片底部的分页控件旁打印可见行数摘要。

内部 Grid

Grid 公开完整的 TsgcHTMLComponent_Grid — 可直接在其上设置 StripedBordered、列、排序/筛选等。

分页

Pagination 公开 TsgcHTMLComponent_Pagination 实例,用于 CurrentPagePageSizeTotalItems

布局

TableID 标识卡片和内部表格;ToolbarClass 覆盖默认的工具栏行类。

继续探索

所有 sgcHTML 组件浏览 60 多个组件的完整功能矩阵。
下载免费试用版30 天试用版附带 60.HTML 演示项目。
价格Single、Team 和 Site 授权,均含完整源代码。

准备好开始了吗?

下载免费试用版,开始在 Delphi、C++ Builder 和 .NET 中构建 Web 界面。