Grid

TsgcHTMLComponent_Grid — 一个功能丰富的 HTML 数据网格,支持排序、筛选、CSV/PDF 导出、内联编辑、分组、虚拟滚动和 AI 查询,适用于 Delphi、C++ Builder 和 .NET。

TsgcHTMLComponent_Grid

定义 Columns,推入行(或绑定数据集),切换您想要的交互功能,然后读取 HTML 属性。

组件类

TsgcHTMLComponent_Grid

渲染为

Bootstrap 5 <table> + 交互脚本

语言

Delphi, C++ Builder, .NET

定义列、添加行、渲染它

为每个字段添加一个 Columns.Add 条目,用 AddRow 推入行,启用 ShowSort/ShowFilter/ShowExport,然后读取 HTML

uses
  sgcHTML_Component_Grid;

var
  oGrid: TsgcHTMLComponent_Grid;
begin
  oGrid := TsgcHTMLComponent_Grid.Create(nil);
  try
    oGrid.TableID := 'orders';
    oGrid.Striped := True;
    oGrid.Hover := True;
    oGrid.ShowSort := True;
    oGrid.ShowFilter := True;
    oGrid.ShowExport := True;

    oGrid.Columns.Add.Title := 'Customer';
    oGrid.Columns.Add.Title := 'Country';
    oGrid.Columns.Add.Title := 'Total';

    oGrid.AddRow(['Alfreds', 'Germany', '1,200']);
    oGrid.AddRow(['Around the Horn', 'UK', '1,900']);

    WebModule.Response := oGrid.HTML;   // Bootstrap table + script
  finally
    oGrid.Free;
  end;
end;

// Or bind it straight to a dataset:
oGrid.LoadFromDataSet(qryOrders);
// includes: sgcHTML_Component_Grid.hpp

TsgcHTMLComponent_Grid *oGrid = new TsgcHTMLComponent_Grid(NULL);
try
{
  oGrid->TableID = "orders";
  oGrid->Striped = true;
  oGrid->Hover = true;
  oGrid->ShowSort = true;
  oGrid->ShowFilter = true;
  oGrid->ShowExport = true;

  oGrid->Columns->Add()->Title = "Customer";
  oGrid->Columns->Add()->Title = "Country";
  oGrid->Columns->Add()->Title = "Total";

  oGrid->AddRow(OPENARRAY(String, ("Alfreds", "Germany", "1,200")));
  oGrid->AddRow(OPENARRAY(String, ("Around the Horn", "UK", "1,900")));

  String html = oGrid->HTML;   // Bootstrap table + script
}
__finally
{
  delete oGrid;
}
using esegece.sgcWebSockets;

var grid = new TsgcHTMLComponent_Grid();
grid.TableID = "orders";
grid.Striped = true;
grid.Hover = true;
grid.ShowSort = true;
grid.ShowFilter = true;
grid.ShowExport = true;

grid.Columns.Add().Title = "Customer";
grid.Columns.Add().Title = "Country";
grid.Columns.Add().Title = "Total";

grid.AddRow(new string[] { "Alfreds", "Germany", "1,200" });
grid.AddRow(new string[] { "Around the Horn", "UK", "1,900" });

string html = grid.HTML;   // Bootstrap table + script

关键属性与方法

您最常使用的成员。

列与行

Columns(每个项目都有 TitleNameWidthAlign);AddRow(values) 追加一行;Rows 公开制表符分隔的后备列表;Clear 清空它。

数据集绑定

LoadFromDataSet 有三个重载 — 所有字段、命名字段列表或最大行数上限 — DataSource 驱动实时刷新。

样式

StripedBorderedHoverResponsiveDarkCSSClass 映射到 Bootstrap 表格类。

交互性

ShowSortShowFilterShowExport(CSV + PDF)、InlineEdit 配合 EditMode,以及 ColumnReorder 添加客户端行为。

分组与滚动

ShowGrouping + GroupByColumn 渲染分组标题;VirtualScroll 配合 VisibleRowsVirtualScrollURL 在显示时加载更多行。

AI 查询

AIQueryEnabled 添加一个询问栏(AIQueryPlaceholderAIQueryButtonTextAIQueryButtonStyle);ProcessAIQuery 触发 OnAIQuery 事件。

继续探索

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

准备好开始了吗?

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