ListGroup
TsgcHTMLComponent_ListGroup — render a list group of links or items with badges and content, from your own items or directly from a dataset, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_ListGroup — render a list group of links or items with badges and content, from your own items or directly from a dataset, in Delphi, C++ Builder and .NET.
A list component that emits a Bootstrap 5 list-group. Add items (with optional badges and content), set the flush / numbered / horizontal flags, then read the HTML property.
TsgcHTMLComponent_ListGroup
Bootstrap 5 list-group markup
Delphi, C++ Builder, .NET
Call AddItem(text, href, badge, badgeStyle) for each row (or push into Items directly), set the layout flags, then read HTML (or drop it into a TsgcHTMLTemplate_Bootstrap page).
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");
The members you reach for most often.
Items is the TsgcHTMLListGroupItems collection; each TsgcHTMLListGroupItem carries Text, Href, Badge, BadgeStyle, Active, Disabled and Content.
AddItem(aText, aHref, aBadge, aBadgeStyle) appends a row in one call; a non-empty Href renders the item as a clickable list-group-item-action link.
LoadFromDataSet(aDataSet, aTextField, aHrefField, aBadgeField) fills the list from a query, one item per row.
Set an item's Badge with a BadgeStyle (a TsgcHTMLBadgeStyle such as bgPrimary) for a pill counter, and Content for a secondary description line.
Flush removes the outer borders, Numbered renders an ordered list-group-numbered, and Horizontal lays items out in a row.
HTML returns the list-group markup and ListGroupID sets its element id — serve it, or assign it to a page template's BodyContent.