EmptyState 组件 — sgcHTML | eSeGeCe

EmptyState

TsgcHTMLComponent_EmptyState — 当表格、列表或搜索结果没有数据行时显示的面板:图标或图片、标题、描述,以及最多两个按钮,适用于 Delphi、C++ Builder 和 .NET。

TsgcHTMLComponent_EmptyState

设置 IconTitleDescription,然后读取 HTML 属性;它完全不产生任何脚本,因此可以安全地按页面需要多次作为带外片段推送。

组件类

TsgcHTMLComponent_EmptyState

渲染为

单个占位 <div>,无脚本

语言

Delphi, C++ Builder, .NET

得体地表达“这里没有内容”

Icon 接受 CSS 图标类或内联 SVG 标记,会在经过简单的安全检查后原样输出;切勿将最终用户输入绑定到它 — 不受信任的文本应绑定到 TitleDescription,这两者始终会进行 HTML 编码。

uses
  sgcHTML_Enums, sgcHTML_Component_EmptyState;

var
  oEmpty: TsgcHTMLComponent_EmptyState;
begin
  oEmpty := TsgcHTMLComponent_EmptyState.Create(nil);
  try
    oEmpty.Icon := 'bi bi-inbox';
    oEmpty.Title := 'No results';
    oEmpty.Description := 'Try a different search, or clear your filters.';
    oEmpty.ActionCaption := 'Clear filters';
    oEmpty.ActionHref := '/orders';
    oEmpty.ActionStyle := bsPrimary;

    WebModule.Response := oEmpty.HTML;
  finally
    oEmpty.Free;
  end;
end;

// Or the one-line static helper for the simple case:
WebModule.Response := TsgcHTMLComponent_EmptyState.Build('No results', 'Try a different search.');
// includes: sgcHTML_Component_EmptyState.hpp

TsgcHTMLComponent_EmptyState *oEmpty = new TsgcHTMLComponent_EmptyState(NULL);
try
{
  oEmpty->Icon = "bi bi-inbox";
  oEmpty->Title = "No results";
  oEmpty->Description = "Try a different search, or clear your filters.";
  oEmpty->ActionCaption = "Clear filters";
  oEmpty->ActionHref = "/orders";
  oEmpty->ActionStyle = bsPrimary;

  String html = oEmpty->HTML;
}
__finally
{
  delete oEmpty;
}

// Or the one-line static helper for the simple case:
String html2 = TsgcHTMLComponent_EmptyState::Build("No results", "Try a different search.");
using esegece.sgcWebSockets;

var empty = new TsgcHTMLComponent_EmptyState();
empty.Icon = "bi bi-inbox";
empty.Title = "No results";
empty.Description = "Try a different search, or clear your filters.";
empty.ActionCaption = "Clear filters";
empty.ActionHref = "/orders";
empty.ActionStyle = ButtonStyle.bsPrimary;

string html = empty.HTML;

// Or the one-line static helper for the simple case:
string html2 = TsgcHTMLComponent_EmptyState.Build("No results", "Try a different search.");

关键属性与方法

您最常使用的成员。

Icon / ImageURL

CSS 图标类或内联 SVG(经过净化,拒绝时会丢弃);当两者都设置时,ImageURL 优先于 Icon

Title / Description

始终经过 HTML 编码,是绑定数据库或用户提供文本的安全组合。

ActionCaption / ActionHref / ActionStyle

主操作按钮,通过共享的 TsgcHTMLButtonStyle 枚举设置样式,默认值为 bsPrimary

SecondaryActionCaption / SecondaryActionHref

第二个按钮,始终为描边样式,没有自己的样式属性。

Compact

为较小的嵌入区域(一个部件、一个表格主体)使用更紧凑的内边距,而不是整个页面/区块。

Build

类函数:在一次调用中构造、设置 Title/Description、渲染并释放一个临时实例。

继续探索

在线帮助此组件的完整 API 参考和使用指南。
所有 sgcHTML 组件浏览 80 多个组件的完整功能矩阵。
下载免费试用版30 天试用版附带 60.HTML 演示项目。
价格Single、Team 和 Site 授权,均含完整源代码。
超值之选:All-AccesseSeGeCe 全部产品,含高级支持,每年 €1,059 起。
查看 All-Access 价格

准备好开始了吗?

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