|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
Hello all,
I first created my menu manually to get it to look and feel how I wanted. Now I am databinding to it but I have not been successful in figuring out how to add a separator between each databound item.
For instance:
I want this -> Common Tasks | About Us | Contact Us
The "|" is the separator
What I get is -> Common Tasks About Us Contact Us
Any ideas?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Our menu doesn't recongize '|' or '-', in order to create a separator during data binding, you would need to handle ItemDataBound event, at which point you can set the newly created item's IsSeparator to true base don Menu.DataItem. DataItem contains the current "data item" that was used to create the menu item.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
Cool, thanks. I didn't see the events as I was looking at the TemplateItem, instead of the Menu itself... DUH!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
So do you mean that I would need to have separator items in my datatable in order to use them with the databound menu?
I.E. My table would need to look like this:
Item 1 -> Common Tasks Item 2 -> | Item 3 -> About Us Item 4 -> | Item 5 -> Contact Us
Or could my datatable look like this:
Item 1 -> Common Tasks Item 2 -> About Us Item 3 -> Contact Us
?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You do not have to have separator physically in your database. But you definitely need something in your data source if you want to do it through data binding. If you bind it to db, then each item is created based on a "record", separator is also an item, so the record has to be there.
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
I have added the separator "|" to my datatable via c# code, however it still does not display when I set IsSeparator = true for the items that have "|" for their text.
If I don't set the IsSeparator attribute then it shows.
What am I doing wrong?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hum....then probablly a regular item will work just fine for you. :) There are generally two ways to display a separator, using the build in separator support; or use regular menu items. When you use built-in separator support, you would need to set properties on LookItems._Separator in order to control how your separator would look like. The otherwise is to use a regular item, you can use the pipe character "|" or even an image. It will display whatever you provide.
The biggest difference between "separator item" and "non separator item" is separator use a different look item (LookItems._Separator), it also can not have left/right images.
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
I have not been successful in getting either method to work.
My results: When I use a regular menu item with "Text-Html='|'" it makes that menu item the same width as my other menu items (about 147 pixels too wide). I was not successful in finding out where to set the _Separator LookItem in the code-behind. I found where I could set it within the Menu Builder but that didn't seem to work for me either.
Any ideas?
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
I got it to work using a regular menu item. The problem was that it was not taking the width of 1px that I had set in the CSS file. I had to set MenuItem.Width = 1 for it to work.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Cool! You are absolutely right --- it does not take the width set in CSS, that's exactly why we have a separate Width property. :)
|
|