|
Rank: Newbie Groups: Member
Joined: 1/14/2010 Posts: 3
|
Hello
I am populating a menu from an xml file with the following sample structure.
<items> <category title="Home" url="~/adminWhoOnline.aspx"/> <category title="|"/> <category title="Courses"> <category title="Course list" url="~/adminCourseList.aspx"/> <category title="Add a new course" url="~/adminCourseAdd.aspx" /> </category> </items>
I'd like to be able to add a shortcut key to each of the top level menu items. I have set the EnableKeyboardNavigation property of the eo:Menu control to true but am unsure about what else to do.
Do I need to add an attribute to the XML datasource that is then processed during the ItemDataBound event? Or is there some other approach?
Can you suggest a solution? Your demos don't seem to cover dynamically generated menu systems in much details.
Thanks in advance.
Sas
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
If you only need to support regular key navigation such as arrow, enter and esc key, then setting EnableKeyboardNavigation is sufficient. Otherwise you will need to set the item's ShortCut property and you can do it during ItemDataBound event as you suggested. I believe that's the easiest approach. You want to be careful about the short cut you choose though because browser itself has all kind of short cuts and so you do not want to conflict with those.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2010 Posts: 3
|
Thanks for the reply.
Do you have some sample code that you can post? I tried setting the property during binding but wasn't successful.
Thanks
Sas
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Here is the sample code:
Code: XML
<items>
<category title="Hardware" shortcut="Ctrl+Shift+H">
</category>
<category title="Software">
</category>
</items>
Code: HTML/ASPX
<eo:Menu .....>
<TopGroup>
<Bindings>
<eo:DataBinding DataField="@shortcut" Property="Shortcut" />
</Bindings>
</TopGroup>
</eo:Menu>
Note the DataBinding object inside the menu that maps "@shortcut" to property ShortCut. "@shortcut" is an XPath expression. This way you don't have to handle ItemDataBound event. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2010 Posts: 3
|
Thanks very much. Your code works like a charm. I also added the binding to the menu items as well so we can jump straight to sub menus with shortcuts.
I hadn't come across the <Bindings> tag before. Is this documented anywhere in your help files? I couldn't find it and wonder if there are other pieces of functionality that I am missing out on.
Thanks very much for your help. You have really made our application much more accessible.
Sas
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You are very welcome. Here is the related documentation: http://doc.essentialobjects.com/library/1/menucommon/databinding/populate_datasource.aspxLook for "Using DataBinding object" section. Thanks!
|
|