Welcome Guest Search | Active Topics | Sign In | Register

SlideMenu demo code not working as expected Options
Koolworld
Posted: Monday, February 18, 2008 3:41:07 AM
Rank: Newbie
Groups: Member

Joined: 2/18/2008
Posts: 5
Hi, i'm looking at the SlideMenu control and using the databinding demo code to evaluate it (from the Menu control), but the problem i have is that the menu will not expand and instead just navigates to the URL for that parent node.

It's using this datatable from your example:

Code: Visual Basic.NET
Dim table As New DataTable()
        table.Columns.Add("Country", GetType(String))
        table.Columns.Add("State", GetType(String))
        table.Columns.Add("City", GetType(String))
        table.Columns.Add("WebSite", GetType(String))
        table.Columns.Add("Population", GetType(Integer))
        table.Rows.Add(New Object() {"U.S.A", "GA", "Atlanta", "Category.aspx?c=20", "123456"})
        table.Rows.Add(New Object() {"U.S.A", "GA", "Savannah", "Category.aspx?c=20", "200000"})
        table.Rows.Add(New Object() {"U.S.A", "FL", "Miami", "Category.aspx?c=20", "3000"})
        table.Rows.Add(New Object() {"U.S.A", "FL", "Orlando", "Category.aspx?c=20", "4000"})
        table.Rows.Add(New Object() {"Canada", "ON", "Toronto", "Category.aspx?c=20", "50000"})


and this in the Page_Load:

Code: Visual Basic.NET
' Bind the "Website" column in the table to "NavigateUrl"
        ' property.
        Dim binding As New EO.Web.DataBinding()
        binding.DataField = "WebSite"
        binding.Property = "NavigateUrl"

 ' Add this MenuDataBinding class into the group's binding
        ' collection.
        SlideMenu1.Bindings.Add(binding)


if i remove the binding, it expands as expected but not menu items have a navigate URL.

Can you please point me to demo code for databinding using the SlideMenu?

Thanks.
eo_support
Posted: Monday, February 18, 2008 6:21:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

Expand/collapse occurs within the same page. So when you navigate to another page, the expand/collapse status is lost.

The easiest way to make the slide menu expand/collapse across pages is to set this property to "NavigateUrl":

http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.BaseNavigator.AutoSelectSource.html

This way when you navigate to the new page, the slide menu automatically select (for slide menu, that also means expand) the item whose NavigateUrl matches the current page Url.

Thanks
Koolworld
Posted: Monday, February 18, 2008 7:09:49 AM
Rank: Newbie
Groups: Member

Joined: 2/18/2008
Posts: 5
Can i not have it so that the parent menu items don't navigate, just expand, but only the child items do navigate?
eo_support
Posted: Monday, February 18, 2008 7:34:57 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

Yes. In that case you should not give the parent item NavigateUrl. When the slide menu populates from a DataTable, it uses the first row of the same group to populate the parent item, so the following row is used to populate both the parent item and the first child item:

table.Rows.Add(New Object() {"U.S.A", "GA", "Atlanta", "Category.aspx?c=20", "123456"})

Thus the parent item also gets NavigateUrl value "Category.aspx?c=20". There are a number of ways to avoid this:

1. Set your DataBinding object's Depth property to 1. That way it would skip level 0, which is the top level; or
2. Clear out NavigateUrl once you are done with data binding:

Code: C#
SlideMenu1.DataBind();
foreach (EO.Web.MenuItem item in SlideMenu1.Items)
    item.NavigateUrl = null;


3. You can also handle the slide menu's ClientSideOnItemClick to return false for top level items. This would be an option if you are already handling client side event. Otherwise it might be too much work;

Thanks
Koolworld
Posted: Tuesday, February 19, 2008 1:26:09 AM
Rank: Newbie
Groups: Member

Joined: 2/18/2008
Posts: 5
Thanks, number 1 did the trick!
Koolworld
Posted: Tuesday, February 19, 2008 8:47:21 AM
Rank: Newbie
Groups: Member

Joined: 2/18/2008
Posts: 5
Hi, just to follow up on something here, can i use something like option 2 method to go through all the items in a menu - as the SlideMenu1.Items only seems to contain the toplevel items and not the submenu items, etc. I want to go through all menu items and replace empty ones.
Thanks
eo_support
Posted: Tuesday, February 19, 2008 8:57:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

You can do that by check each menu item's SubMenu property, then check SubMenu.Items property, and so on. Menu items are organized like file directories. At any time you only see one level below.

Thanks
Koolworld
Posted: Tuesday, February 19, 2008 9:06:06 AM
Rank: Newbie
Groups: Member

Joined: 2/18/2008
Posts: 5
That's great, seems to work well. I've got one more question for you. When binding data to the slidemenu via a datatable, i setup my SlideMenu1.DataFields which determine what text is displayed for each menu item level, but can i access the other data (loaded from the datatable)? I want to amend some of the NavigateUrl properties by adding on the ID of each record to the NavigateUrl as a querystring - can i access this data from the SlideMenu control?
eo_support
Posted: Tuesday, February 19, 2008 9:10:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
You can access data from the same record, but not from other record. To do so you would handle the slide menu's ItemDataBound event. Inside that event you can modify the menu item's properties based on the menu item's DataItem property:

http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.NavigationItem.DataItem.html


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.