Click or drag to resize

ListWidget Class

The class DashboardWidget provides base list dashboard widget
Inheritance Hierarchy

Namespace:  Dynamicweb.Dashboards.Widgets
Assembly:  Dynamicweb.Dashboards (in Dynamicweb.Dashboards.dll) Version: 2.9.4
Syntax
[AddInIconAttribute(KnownIcon.List)]
public abstract class ListWidget : DashboardElementWidget

The ListWidget type exposes the following members.

Constructors
  NameDescription
Public methodListWidget
The list widget default constructor
Top
Properties
  NameDescription
Public propertyColumns
Gets or sets widget size
(Inherited from DashboardWidget.)
Public propertyCreatedDate
Gets the created date and time.
(Inherited from DashboardWidget.)
Public propertyElement
The to be shown
(Inherited from DashboardElementWidget.)
Public propertyId
Gets widget Id
(Inherited from DashboardWidget.)
Protected propertyInstantFetch
Gets or sets value indicating whether data should be fetch to widget instantly, otherwise - using ajax
Public propertyModifiedDate
Gets the last modified date and time.
(Inherited from DashboardWidget.)
Public propertyNoItemsMessage
Message to display if the list has no items.
Public propertyOrder
Gets or sets widget order
(Inherited from DashboardWidget.)
Public propertyShowTitle
Gets or sets value indicating whether to show widget title.
(Inherited from DashboardWidget.)
Public propertyTitle
Gets or sets widget title
(Inherited from DashboardWidget.)
Public propertyTitleAction
Gets or sets widget title action
(Inherited from DashboardWidget.)
Top
Methods
  NameDescription
Public methodFetch
Fetches widget with data
(Overrides DashboardWidgetFetch(IDashboard, String).)
Public methodGetIdSuitableString (Inherited from ConfigurableAddIn.)
Public methodGetItems
Gets list items
Public methodGetOptions
Return dropdown options
(Inherited from DashboardWidget.)
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
(Inherited from DashboardElementWidget.)
Public methodRenderAdditionalContent (Inherited from ConfigurableAddIn.)
Public methodScriptDependencies
Specifies relative paths to all script files that this widget is dependent upon.
(Inherited from DashboardWidget.)
Public methodSetValue (Inherited from ConfigurableAddIn.)
Public methodStylesheetDependencies
Specifies relative paths to all style files that this widget is dependent upon.
(Inherited from DashboardWidget.)
Public methodUpdateFromPost (Inherited from ConfigurableAddIn.)
Top
Examples
How to inherit ListWidget
using Dynamicweb.Dashboards.Widgets;
using Dynamicweb.UI.Elements.Displays;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Core;

namespace Dynamicweb.Dashboards.Examples
{
    [AddInName("Top files folders size")]
    [AddInDescription("Show files folders sizes")]
    [AddInIcon(Core.UI.Icons.KnownIcon.Healing)]
    public class FilesFolderSizes : ListWidget
    {
        const string Folder = "/Files";

        public FilesFolderSizes()
        {
            Title = "Top space-hogging files folders";
        }

        [AddInParameterEditor("", "")]
        public override int Columns
        {
            get { return base.Columns; }
            set { base.Columns = value; }
        }

        public override IEnumerable<ListViewItem> GetItems(IDashboard dashboard, string path)
        {
            var filesPath = SystemInformation.MapPath(Folder);

            var items = from dirPath in Directory.GetDirectories(filesPath)
                        let dirInfo = new DirectoryInfo(dirPath)
                        let dirSize = Helper.DirSize(dirInfo)
                        orderby dirSize descending
                        select new
                        {
                            Name = dirInfo.Name,
                            Size = dirSize
                        };

            double count;
            string subtitle;
            foreach (var item in items.Take(4))
            {
                Helper.HumanizeByteSize(item.Size, out count, out subtitle);
                yield return new ListViewItem()
                {
                    Icon = Core.UI.Icons.KnownIcon.Folder,
                    Title = item.Name,
                    Hint = string.Format("The folder size {0:0.##} {1}", count, subtitle)
                };
            }
        }
    }
}
See Also