DashboardWidget Class |
Namespace: Dynamicweb.Dashboards.Widgets
The DashboardWidget type exposes the following members.
Name | Description | |
---|---|---|
DashboardWidget | Initializes a new instance of the DashboardWidget class |
Name | Description | |
---|---|---|
Columns |
Gets or sets widget size
| |
CreatedDate |
Gets the created date and time.
| |
Id |
Gets widget Id
| |
ModifiedDate |
Gets the last modified date and time.
| |
Order |
Gets or sets widget order
| |
ShowTitle |
Gets or sets value indicating whether to show widget title.
| |
Title |
Gets or sets widget title
| |
TitleAction |
Gets or sets widget title action
|
Name | Description | |
---|---|---|
Fetch |
Fetches widget data from storage
| |
GetIdSuitableString | (Inherited from ConfigurableAddIn.) | |
GetOptions |
Return dropdown options
| |
GetParametersToXml | (Inherited from ConfigurableAddIn.) | |
GetParametersToXml(Boolean) | (Inherited from ConfigurableAddIn.) | |
LoadParametersFromXml | (Inherited from ConfigurableAddIn.) | |
Render |
The method render widget and return html
| |
RenderAdditionalContent | (Inherited from ConfigurableAddIn.) | |
ScriptDependencies |
Specifies relative paths to all script files that this widget is dependent upon.
| |
SetValue | (Inherited from ConfigurableAddIn.) | |
StylesheetDependencies |
Specifies relative paths to all style files that this widget is dependent upon.
| |
UpdateFromPost | (Inherited from ConfigurableAddIn.) |
using Dynamicweb.Dashboards.Widgets; using Dynamicweb.Extensibility.AddIns; using System; namespace Dynamicweb.Dashboards.Examples { [AddInName("Date time widget")] [AddInDescription("Show current date and time")] [AddInIcon(Core.UI.Icons.KnownIcon.LocalHotel)] public sealed class SimpleHtmlWidget : DashboardWidget { private string currentDate = string.Empty; private string currentTime = string.Empty; public SimpleHtmlWidget() { Columns = 2; } public override void Fetch(IDashboard dashboard, string path) { var dt = DateTime.Now; currentTime = dt.ToShortTimeString(); currentDate = dt.ToShortDateString(); } public override string Render() { var str = $"<div style=\"text-align: center; position:relative;min-height:161px;\"><div style=\"position: absolute;top: 50%;transform: translate(0, -50%);width: 100%;font-size: 170%;\"><span id=\"smpl-time-{Id}-time\">{currentTime}</span><br /><small id=\"smpl-time-{Id}-date\">{currentDate}</small></div></div>"; str += $"<script>(function(el) {{setInterval(function() {{var d = new Date();el.innerHTML = d.toLocaleTimeString()}}, 1000);}})(document.getElementById(\"smpl-time-{Id}-time\"));</script>"; return str; } } }