Notification

TsgcHTMLComponent_Notification — renderiza un centro de notificaciones desplegable con icono de campana y una insignia de no leídas, construido a partir de una colección de elementos de notificación, en Delphi, C++ Builder y .NET.

TsgcHTMLComponent_Notification

Un componente de centro de notificaciones que emite un desplegable de Bootstrap 5. Añade elementos a su colección Items (o llama a AddNotification), y luego lee la propiedad HTML — el contador de no leídas UnreadCount alimenta la insignia.

Clase de componente

TsgcHTMLComponent_Notification

Renderiza

Marcado de desplegable de Bootstrap 5

Lenguajes

Delphi, C++ Builder, .NET

Créalo, añade notificaciones, renderízalo

Define Title y MaxVisible, llama a AddNotification(title, message, color, timestamp) por cada entrada, y luego lee HTML. El contador de no leídas rellena la insignia automáticamente.

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;

Propiedades y métodos clave

Los miembros que más vas a usar.

Items

Items es una colección TsgcHTMLNotificationItems; cada TsgcHTMLNotificationItem tiene Title, Message, Timestamp, Color, Icon, Href y Read.

Añadir notificaciones

AddNotification(title, message, color, timestamp) añade un elemento y usa la hora actual como valor por defecto del timestamp cuando se omite.

Insignia de no leídas

UnreadCount cuenta los elementos cuyo Read es False; ShowBadge activa o desactiva la píldora roja y GetBadgeHTML devuelve solo el marcado de la insignia.

Cabecera

Title define el encabezado del desplegable, EmptyText el texto de relleno cuando no hay elementos y BellIcon el glifo del disparador.

Límites

MaxVisible limita cuántos elementos se renderizan (por defecto 5), con un enlace "View all" cuando hay más; NotificationID asigna el id del elemento.

Salida

HTML devuelve el desplegable completo con icono de campana junto con su CSS con ámbito — sírvelo, o asígnalo al BodyContent de una plantilla de página.

Sigue explorando

Todos los componentes sgcHTMLExplora la matriz completa de más de 60 componentes.
Descargar prueba gratuitaLa prueba de 30 días incluye los proyectos demo 60.HTML.
PreciosLicencias Single, Team y Site con código fuente completo.

¿Listo para empezar?

Descarga la prueba gratuita y empieza a crear interfaces web en Delphi, C++ Builder y .NET.