Using an existing ScreenType
Creating a custom screen using an existing screen type
Now that we have created the Queries and Commands needed for our Screens, we can start implementing the actual screens. DynamicWeb provides three built-in ScreenTypes, which can be used for creating a custom screen:
When you use one of the standard ScreenTypes, you don’t have to worry about the look and feel of your screen, as we’ve taken care of that part – you just need to concentrate on your data.
All of the standard ScreenTypes are located in Dynamicweb.CoreUI.Screens, and contain methods that you need to override to put something on the screen.
In the example below we inherit from ListScreenBase – in this case for the HealthProviderCheckDataModel – and use two overrides to add Name and Columns to the screen:
public sealed class HealthProviderCheckListScreen : ListScreenBase<HealthProviderCheckDataModel>
{
// Override default values
protected override string GetScreenName() => "Health checks";
protected override IEnumerable<ListViewMapping> GetViewMappings()
{
var rowMapping = new RowViewMapping
{
Columns = new System.Collections.Generic.List<ModelMapping>
{
CreateMapping(p => p.State),
CreateMapping(p => p.Name),
CreateMapping(p => p.Description),
CreateMapping(p => p.Count)
}
};
return new ListViewMapping[] { rowMapping };
}
}
Once this new Screen has been added to the area tree you can navigate to it and view the result:
