Work with Dashboard via code.



Is it possible to work with dashboard via code.

For example: Create Tab and gadget inside it? Or delete it?

Nov 14, 2018 10:56

Hi Roman,

It's not something I've worked with before but you'll want to make use of the PersonalizedViewSettingsManager and/or the IPersonalizedViewSettingsRepository Interface.

I just put together this sample which shows creating a tab, naming it 'Test' and adding a Notes gadget to it:

var viewManager = ServiceLocator.Current.GetInstance<IViewManager>();
var personalizedViewSettingsManager = ServiceLocator.Current.GetInstance<PersonalizedViewSettingsManager>();
var componentManager = ServiceLocator.Current.GetInstance<IComponentManager>();

var user = HttpContext.User;
const string dashboardViewName = "/episerver/dashboard";

ICompositeView compositeView = viewManager.CreateView(dashboardViewName, user);

// Get the tab container, this should always be below our root container
var tabContainer = (TabContainer)compositeView.RootContainer.Components.First(x => x.DefinitionName.Equals(typeof(TabContainer)

PersonalizedViewSettings personalizedViewSettings;
IContainer container;

tabContainer = (TabContainer)personalizedViewSettingsManager.GetOrCreatePersonalizedComponent(user,
    dashboardViewName, tabContainer.Id, out personalizedViewSettings, out container);

// Create a ComponentContainer for our new tab
var singleTabContainer = (ComponentContainer)componentManager.CreateComponent(typeof(ComponentContainer).FullName, user);


var notesComponent = componentManager.CreateComponent("EPiServer.Cms.Shell.UI.Controllers.NotesController", user);

// Set the heading & add the notes gadget
singleTabContainer.Settings["personalizableHeading"] = "Test";


There are very likely some improvements that can be made to this - but it should give you a starting point.


Nov 14, 2018 18:46

Hi Jake,


I`ll try it.

Nov 15, 2018 7:45
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.