EmptyState
TsgcHTMLComponent_EmptyState — 当表格、列表或搜索结果没有数据行时显示的面板:图标或图片、标题、描述,以及最多两个按钮,适用于 Delphi、C++ Builder 和 .NET。
TsgcHTMLComponent_EmptyState — 当表格、列表或搜索结果没有数据行时显示的面板:图标或图片、标题、描述,以及最多两个按钮,适用于 Delphi、C++ Builder 和 .NET。
设置 Icon、Title 和 Description,然后读取 HTML 属性;它完全不产生任何脚本,因此可以安全地按页面需要多次作为带外片段推送。
Icon 接受 CSS 图标类或内联 SVG 标记,会在经过简单的安全检查后原样输出;切勿将最终用户输入绑定到它 — 不受信任的文本应绑定到 Title 和 Description,这两者始终会进行 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.");
您最常使用的成员。
CSS 图标类或内联 SVG(经过净化,拒绝时会丢弃);当两者都设置时,ImageURL 优先于 Icon。
始终经过 HTML 编码,是绑定数据库或用户提供文本的安全组合。
主操作按钮,通过共享的 TsgcHTMLButtonStyle 枚举设置样式,默认值为 bsPrimary。
第二个按钮,始终为描边样式,没有自己的样式属性。
为较小的嵌入区域(一个部件、一个表格主体)使用更紧凑的内边距,而不是整个页面/区块。
类函数:在一次调用中构造、设置 Title/Description、渲染并释放一个临时实例。