[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]
- 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
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)); |
} |
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