Notification
TsgcHTMLComponent_Notification — render een meldingscentrum met een bel-icoon-dropdown en een ongelezen-badge, opgebouwd uit een verzameling meldingsitems, in Delphi, C++ Builder en .NET.
TsgcHTMLComponent_Notification — render een meldingscentrum met een bel-icoon-dropdown en een ongelezen-badge, opgebouwd uit een verzameling meldingsitems, in Delphi, C++ Builder en .NET.
Een meldingscentrum-component die een Bootstrap 5-dropdown genereert. Voeg items toe aan de Items-verzameling (of roep AddNotification aan) en lees vervolgens de eigenschap HTML — de ongelezen UnreadCount stuurt de badge aan.
TsgcHTMLComponent_Notification
Bootstrap 5 dropdown-markup
Delphi, C++ Builder, .NET
Stel Title en MaxVisible in, roep AddNotification(title, message, color, timestamp) aan voor elk item en lees vervolgens HTML. Het aantal ongelezen items vult de badge automatisch.
uses
sgcHTML_Enums, sgcHTML_Component_Notification;
var
oNotif: TsgcHTMLComponent_Notification;
begin
oNotif := TsgcHTMLComponent_Notification.Create(nil);
try
oNotif.Title := 'Notifications';
oNotif.MaxVisible := 5;
oNotif.ShowBadge := True;
oNotif.AddNotification('New order',
'Order #1042 was placed.', hcSuccess, '2 min ago');
oNotif.AddNotification('Payment failed',
'Invoice #88 could not be charged.', hcDanger, '10 min ago');
WebModule.Response := oNotif.HTML; // bell dropdown + badge
finally
oNotif.Free;
end;
end;
// Or add items via the Items collection directly:
with oNotif.Items.Add do
begin
Title := 'Welcome';
Message := 'Your account is ready.';
Color := hcInfo;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Notification.hpp
TsgcHTMLComponent_Notification *oNotif = new TsgcHTMLComponent_Notification(NULL);
try
{
oNotif->Title = "Notifications";
oNotif->MaxVisible = 5;
oNotif->ShowBadge = true;
oNotif->AddNotification("New order",
"Order #1042 was placed.", hcSuccess, "2 min ago");
oNotif->AddNotification("Payment failed",
"Invoice #88 could not be charged.", hcDanger, "10 min ago");
String html = oNotif->HTML; // bell dropdown + badge
}
__finally
{
delete oNotif;
}
// Or add items via the Items collection directly:
TsgcHTMLNotificationItem *item = oNotif->Items->Add();
item->Title = "Welcome";
item->Message = "Your account is ready.";
item->Color = hcInfo;
using esegece.sgcWebSockets;
var notif = new TsgcHTMLComponent_Notification();
notif.Title = "Notifications";
notif.MaxVisible = 5;
notif.ShowBadge = true;
notif.AddNotification("New order",
"Order #1042 was placed.", TsgcHTMLColor.hcSuccess, "2 min ago");
notif.AddNotification("Payment failed",
"Invoice #88 could not be charged.", TsgcHTMLColor.hcDanger, "10 min ago");
string html = notif.HTML; // bell dropdown + badge
// Or add items via the Items collection directly:
var item = notif.Items.Add();
item.Title = "Welcome";
item.Message = "Your account is ready.";
item.Color = TsgcHTMLColor.hcInfo;
De members die je het vaakst gebruikt.
Items is een TsgcHTMLNotificationItems-verzameling; elk TsgcHTMLNotificationItem heeft Title, Message, Timestamp, Color, Icon, Href en Read.
AddNotification(title, message, color, timestamp) voegt een item toe en zet de tijdstempel standaard op de huidige tijd wanneer die wordt weggelaten.
UnreadCount telt items waarvan Read False is; ShowBadge schakelt de rode pil in of uit en GetBadgeHTML geeft alleen de badge-markup terug.
Title stelt de kop van de dropdown in, EmptyText de tijdelijke tekst wanneer er geen items zijn en BellIcon het trigger-glyph.
MaxVisible beperkt hoeveel items er renderen (standaard 5), met een "View all"-link wanneer er meer zijn; NotificationID kent de element-id toe.
HTML geeft de volledige bel-icoon-dropdown met bijbehorende scoped CSS terug — serveer het of wijs het toe aan de BodyContent van een paginasjabloon.