Command panel: Using multiple command panels

Command panel: Using multiple command panels

Posted on March 25, 2009 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]
 

With the new backend architecture introduced in Sitefinity 3.6 we have introduced an ability to use multiple command panels in a module. The benefits of this approach include following:
  • You can decouple your command panels which makes it easier to inherit and modify them
  • You can group commands into logical units and hide or show them as you see fit
  • You are able to take advantage of conditional command panel loading, which means that you can easily implement logic on which your code will decide which command panels to load
As it was explained in the other articles in this topic, you have variety of options when it comes to creating command panels. You can generate command panels automatically, manually, load whole controls as command panels, regardless if they are User Controls or Custom Controls. What’s even more, you can combine different approaches and for example load command automatically, load a special command panel through a User Control and two other command panels as Custom Controls.

 


How to add multiple command panels


When you are generating commands automatically, all your commands are being added to one default command panel. You can turn this feature on or off as explained in this article.

 

If you are adding command panels manually or by loading Custom Controls, you can add any number of command panels to the list parameter of the method you are overriding.

/// <summary>   
/// Creates the custom command panels.   
/// </summary>   
/// <param name="viewMode">The view mode.</param>   
/// <param name="list">The list.</param>   
protected override void CreateCustomCommandPanels(string viewMode, System.Collections.Generic.List<Telerik.Web.ICommandPanel> list)   
     list.Add(new BooksCommandPanel(this));   
}  
Finally, due to a somewhat special nature of User Controls, the approach for User Control based command panels is slightly different. Instead of adding command panels to the list parameter, you can add any number of virtual paths to the userControls parameter and hence load multiple User Control based command panels.
protected override void CreateCommandPanelsFromUserControls(string viewMode, System.Collections.Generic.List<string> userControls, System.Collections.Generic.List<Telerik.Web.ICommandPanel> list)   
{               
      if (userControls == null
                  userControls = new List<string>(); 
      userControls.Add("~/MyControls/MyCommandPanel.ascx");                   
      base.CreateCommandPanelsFromUserControls(viewMode, userControls, list);   
}  

 

Order of command panels


If you are using one single approach to create command panels (automatic, manually, user controls or custom controls) you are in complete control of the order of command panels and commands; namely they will appear in the same order as you add them to the collections of command panels.
On the other hand, if you are mixing different approaches you should bear in mind that command panels will be loaded in regard to way that they were created and do so like this:
  • Automatically generated commands will be generated first
  • After automatically generated commands, manually created command panels will be loaded
  • After manually created commands, User Control based command panels will be loaded
  • Finally, command panels based on Custom Controls will be loaded
Once again, if the order of command panels is absolutely important to you, you should pick only one of the approaches for creating command panels and add command panels to the collection in order in which you wish them to be displayed.
progress-logo

The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation