ListGroup
TsgcHTMLComponent_ListGroup — 从您自己的项目或直接从数据集渲染由链接或项目组成的列表组,带有徽章和内容,适用于 Delphi、C++ Builder 和 .NET。
TsgcHTMLComponent_ListGroup — 从您自己的项目或直接从数据集渲染由链接或项目组成的列表组,带有徽章和内容,适用于 Delphi、C++ Builder 和 .NET。
一个列表组件,发出 Bootstrap 5 list-group。添加项目(带有可选的徽章和内容),设置 flush / numbered / horizontal 标志,然后读取 HTML 属性。
为每行调用 AddItem(text, href, badge, badgeStyle)(或直接推入 Items),设置布局标志,然后读取 HTML(或将其放入 TsgcHTMLTemplate_Bootstrap 页面)。
uses
sgcHTML_Enums, sgcHTML_Component_ListGroup;
var
oList: TsgcHTMLComponent_ListGroup;
begin
oList := TsgcHTMLComponent_ListGroup.Create(nil);
try
oList.Flush := True;
oList.AddItem('Inbox', '/inbox', '14', bgPrimary);
oList.AddItem('Drafts', '/drafts', '2', bgSecondary);
oList.AddItem('Spam', '/spam', '99+', bgDanger);
WebModule.Response := oList.HTML; // Bootstrap list-group
finally
oList.Free;
end;
end;
// Or fill the list straight from a dataset:
oList.LoadFromDataSet(qryFolders, 'Name', 'Url', 'Unread');
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_ListGroup.hpp
TsgcHTMLComponent_ListGroup *oList = new TsgcHTMLComponent_ListGroup(NULL);
try
{
oList->Flush = true;
oList->AddItem("Inbox", "/inbox", "14", bgPrimary);
oList->AddItem("Drafts", "/drafts", "2", bgSecondary);
oList->AddItem("Spam", "/spam", "99+", bgDanger);
String html = oList->HTML; // Bootstrap list-group
}
__finally
{
delete oList;
}
using esegece.sgcWebSockets;
var list = new TsgcHTMLComponent_ListGroup();
list.Flush = true;
list.AddItem("Inbox", "/inbox", "14", TsgcHTMLBadgeStyle.bgPrimary);
list.AddItem("Drafts", "/drafts", "2", TsgcHTMLBadgeStyle.bgSecondary);
list.AddItem("Spam", "/spam", "99+", TsgcHTMLBadgeStyle.bgDanger);
string html = list.HTML; // Bootstrap list-group
// Or fill the list straight from a dataset:
list.LoadFromDataSet(qryFolders, "Name", "Url", "Unread");
您最常使用的成员。
Items 是 TsgcHTMLListGroupItems 集合;每个 TsgcHTMLListGroupItem 携带 Text、Href、Badge、BadgeStyle、Active、Disabled 和 Content。
AddItem(aText, aHref, aBadge, aBadgeStyle) 通过一次调用追加一行;非空的 Href 会将项目渲染为可点击的 list-group-item-action 链接。
LoadFromDataSet(aDataSet, aTextField, aHrefField, aBadgeField) 从查询填充列表,每行一个项目。
用 BadgeStyle(如 bgPrimary 之类的 TsgcHTMLBadgeStyle)设置项目的 Badge 作为胶囊计数器,用 Content 设置次要描述行。
Flush 移除外边框,Numbered 渲染有序的 list-group-numbered,Horizontal 将项目横向排列。
HTML 返回 list-group 标记,ListGroupID 设置其元素 id — 直接提供服务,或将其赋给页面模板的 BodyContent。