Click or drag to resize

DashboardWidget Class

The class DashboardWidget provides base dashboard widget
Inheritance Hierarchy

Namespace:  Dynamicweb.Dashboards.Widgets
Assembly:  Dynamicweb.Dashboards (in Dynamicweb.Dashboards.dll) Version: 2.9.4
Syntax
[AddInUseParameterOrderingAttribute(true)]
public abstract class DashboardWidget : ConfigurableAddIn, 
	IDropDownOptions

The DashboardWidget type exposes the following members.

Constructors
  NameDescription
Protected methodDashboardWidget
Initializes a new instance of the DashboardWidget class
Top
Properties
  NameDescription
Public propertyColumns
Gets or sets widget size
Public propertyCreatedDate
Gets the created date and time.
Public propertyId
Gets widget Id
Public propertyModifiedDate
Gets the last modified date and time.
Public propertyOrder
Gets or sets widget order
Public propertyShowTitle
Gets or sets value indicating whether to show widget title.
Public propertyTitle
Gets or sets widget title
Public propertyTitleAction
Gets or sets widget title action
Top
Methods
  NameDescription
Public methodFetch
Fetches widget data from storage
Public methodGetIdSuitableString (Inherited from ConfigurableAddIn.)
Public methodGetOptions
Return dropdown options
Public methodGetParametersToXml (Inherited from ConfigurableAddIn.)
Public methodGetParametersToXml(Boolean) (Inherited from ConfigurableAddIn.)
Public methodLoadParametersFromXml (Inherited from ConfigurableAddIn.)
Public methodRender
The method render widget and return html
Public methodRenderAdditionalContent (Inherited from ConfigurableAddIn.)
Public methodScriptDependencies
Specifies relative paths to all script files that this widget is dependent upon.
Public methodSetValue (Inherited from ConfigurableAddIn.)
Public methodStylesheetDependencies
Specifies relative paths to all style files that this widget is dependent upon.
Public methodUpdateFromPost (Inherited from ConfigurableAddIn.)
Top
Examples
How to inherit DashboardWidget
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;
        }
    }
}
See Also