|
Rank: Member Groups: Member
Joined: 7/1/2007 Posts: 17
|
I have tried to use the attached xml sitemap file to populate the SlideMenu object.
In the binding section, I have used four attributes to translate into properties of the slidemenu items.
The first 4 bindings worked very well but I cannot get the visible attribute to bind properly to the Visible property on the SlideMenu. Is there a limitation or bug with the binding of the the visible property?
When I hard code a menu item and set the visible property to false it worked.
Please see the following attached code segment and the attached web.sitemap file.
Thanks
<eo:DataBinding DataField="@title" Property="ItemID" /> <eo:DataBinding DataField="@pageUrl" Property="Value" /> <eo:DataBinding DataField="@expanded" Property="Expanded" /> <eo:DataBinding DataField="@description" Property="ToolTip" /> <eo:DataBinding DataField="@visible" Property="Visible" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="Web.sitemap" XPath="/*/*"> </asp:XmlDataSource>
<eo:SlideMenu DataSourceID="XmlDataSource1" ID="SlideMenu1" runat="server" ControlSkinID="None" SingleExpand="False" Width="195px" CssBlock="" SaveStateCrossPages="True" SlidePaneHeight="130" StateCookieName="SlideMenu" AutoSelectSource="ItemClick" ClientSideOnItemClick="OnMenuItemSelect"> <LookItems> <eo:MenuItem ItemID="_TopGroup"> <SubMenu ItemSpacing="15" LeftIconCellWidth="13" Style-CssText="background-color:#0054e3;cursor:hand;font-family:tahoma;font-size:11px;font-weight:bold;padding-bottom:5px;padding-left:5px;padding-right:5px;padding-top:5px;"> </SubMenu> </eo:MenuItem> <eo:MenuItem Height="25" HoverStyle-CssText="background-image:url("00000002");color:#428EFF;background-position-x: right; background-repeat: no-repeat;background-color:white;" ItemID="_TopLevelItem" LeftIcon-Url="00000012" NormalStyle-CssText="background-image:url("00000001");color:#215DC6;background-position-x: right; background-repeat: no-repeat;background-color:white;" SelectedStyle-CssText="background-image:url("00000003");color:#215DC6;background-position-x: right; background-repeat: no-repeat;background-color:white;"> <SubMenu ItemSpacing="5" LeftIconCellWidth="0" Style-CssText="background-color:#d6dff7;border-bottom-color:white;border-bottom-style:solid;border-bottom-width:1px;border-left-color:white;border-left-style:solid;border-left-width:1px;border-right-color:white;border-right-style:solid;border-right-width:1px;border-top-color:white;border-top-width:1px;color:#215dc6;cursor:hand;font-family:tahoma;font-size:12px;font-weight:normal;padding-bottom:9px;padding-left:0px;padding-right:2px;padding-top:9px;"> </SubMenu> </eo:MenuItem> </LookItems> <TopGroup> <Bindings> <eo:DataBinding DataField="@title" Property="ItemID" /> <eo:DataBinding DataField="@pageUrl" Property="Value" /> <eo:DataBinding DataField="@expanded" Property="Expanded" /> <eo:DataBinding DataField="@description" Property="ToolTip" /> <eo:DataBinding DataField="@visible" Property="Visible" /> </Bindings> </TopGroup> </eo:SlideMenu>
Web.sitemap File
<siteMap> <siteMapNode title="Compliance" pageUrl="" description="Compliance"> <siteMapNode pageUrl="~/Compliance/compreview1.ascx&Deal_Status=Deficient&SubmittedToHO=True" title="Doc Review" description="New Documents "/> <siteMapNode pageUrl="~/Compliance/compreview1.ascx" title="Find Deals" description="Find Deals"/> </siteMapNode> <siteMapNode title="Cheque Processing" pageUrl="" description="Cheque Processing"> <siteMapNode pageUrl="Cheque/FundsToday1.ascx" title="Funds Today" description="Funds & Cheques Entered Today" /> <siteMapNode pageUrl="Cheque/FindCheques1.ascx" title="Find & Edit Cheques" description="Find and Edit Cheques" /> <siteMapNode pageUrl="Cheque/FundsToday1.ascx&action=new_cheque" title="Add Cheque" description="Add New Cheque" visible="false"/> </siteMapNode> </siteMap>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi Tommy,
This is a bug. I've posted a new build for you that addressed this issue. Please see your private message for download location.
Thanks
|
|
Rank: Member Groups: Member
Joined: 7/1/2007 Posts: 17
|
Thanks for the speedy service. Will check it out.
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
I am having the same issue with an older version of the AspxLab Menu. I purchased the menu about a year or so ago, and am unable to use a databinding to the Visible attribute.
Is there a newer build (of the old menu) that I could get?
Edit: I have build 2.7.4.0
Thanks!
Matt LaPora
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The issue has already been fixed in our public download. But you may need a new license for the new version: http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=50A workaround for you is to handle ItemBound event and manually set the Visible property based on your data source. Inside that event you will be able to access DataItem property: http://www.aspxlab.com/doc/AspxLab.WebControls.MenuItem.DataItem.htmlYou can then set the newly created item's Visible property based on that. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
That was what I initially tried, but for some reason the dataitem was always null.
When I used: menu.DataSource = dsMenu (dsMenu is a dataset containing 3 tables, with 2 datarelations and Nested set to true for each relation, and I have verified that the data is accurate and nested appropriately) it gives me a null object for the DataItem property of the MenuItem. However, if I was to use dsMenu.Tables[0] then the DataItem was not null.
I worked around it by using MenuDataBindings, however this made it difficult to handle my OnItemDataBound events appropriately. Instead of being able to use the DataItem, I instead had to check the MenuItem.Text.Html property (which I don't want to do if I can help it).
I can't purchase a new license as my client won't allow it. Thus I am stuck with the old version which gives me a null DataItem when.
DataBinding code:
MenuSystem menuSystem = new MenuSystem();
// Get the menu dataset DataSet dsMenu = menuSystem.BuildMenu();
// Instantiate databinders
AspxLab.WebControls.MenuDataBinding bindingText = new AspxLab.WebControls.MenuDataBinding(); AspxLab.WebControls.MenuDataBinding bindingUrl = new AspxLab.WebControls.MenuDataBinding(); AspxLab.WebControls.MenuDataBinding bindingLook = new AspxLab.WebControls.MenuDataBinding(); AspxLab.WebControls.MenuDataBinding bindingRoles = new AspxLab.WebControls.MenuDataBinding();
//// Set the top menu datasource menuNavigation.DataSource = dsMenu;
//// Set the databindings for the menu bindingText.DataField = "MenuItemText"; bindingText.Property = "Text-Html"; menuNavigation.Bindings.Add(bindingText);
bindingUrl.DataField = "MenuItemNavigateURL"; bindingUrl.Property = "NavigateUrl"; menuNavigation.Bindings.Add(bindingUrl);
bindingLook.DataField = "MenuLook"; bindingLook.Property = "LookID"; menuNavigation.Bindings.Add(bindingLook);
bindingRoles.DataField = "AuthorizedRoles"; bindingRoles.Property = "AllowRoles"; menuNavigation.Bindings.Add(bindingRoles);
ItemDataBound Event Code:
protected void MenuDataBound(object sender, AspxLab.WebControls.MenuItemEventArgs e) { DataRowView view = (DataRowView)e.MenuItem.DataItem; Null DataItem here if attempted, also I am doing this line from memory, so I can't remember if it was DataRow or DataRowView but I tried both.
switch (e.MenuItem.LookID) { case "TopLevelItem_Company": case "TopLevelItem_Services": case "TopLevelItem_Resources": case "TopLevelItem_Customers": case "TopLevelItem_MyAccount": e.MenuItem.Text.Html = ""; break; case "ButtonSeparator": e.MenuItem.IsSeparator = true; break; default: break; }
if (e.MenuItem.Text.Html == "Log In") { if (Context.User.Identity.IsAuthenticated) { e.MenuItem.Visible = false; } } else if (e.MenuItem.Text.Html == "Administration") { e.MenuItem.SubMenu.OffsetY = 0; e.MenuItem.SubMenu.OffsetX = 0; e.MenuItem.SubMenu.ExpandDirection = AspxLab.WebControls.ExpandDirection.Bottom; e.MenuItem.SubMenu.ExpandEffect.Type = AspxLab.WebControls.EffectType.GlideTopToBottom; } else if ((e.MenuItem.Text.Html == "Log in to view this content") || (e.MenuItem.Text.Html == "Goto Login Page")) { if (Context.User.Identity.IsAuthenticated) { e.MenuItem.Visible = false; } } }
menuNavigation.DataBind();
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I am not sure why it would be null. But another workaround is to use an additional MenuDataBinding to store the field that is related to Visible to the menu item's Value property. You can then set the menu item's Visible based on its Value property inside ItemDataBound.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
Heh, that was my second attempt. I got the error "Property 'Visible' does not support data binding". Which in my search for a resolution led me to this thread.
Code I Used:
AspxLab.WebControls.MenuDataBinding bindingVisible = new AspxLab.WebControls.MenuDataBinding();
bindingVisible.DataField = "IsVisible"; bindingVisible.Property = "Visible"; menuNavigation.Bindings.Add(bindingVisible);
Any idea whats up with that?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
No. That's wrong. What I meant is to use a data binding to map it to Value, not Visible:
AspxLab.WebControls.MenuDataBinding bindingVisible = new AspxLab.WebControls.MenuDataBinding();
bindingVisible.DataField = "IsVisible"; bindingVisible.Property = "Value"; menuNavigation.Bindings.Add(bindingVisible);
You will then handle ItemDataBound event to set the menu item's Visible property based on its Value property.
|
|
Rank: Advanced Member Groups: Member
Joined: 9/13/2007 Posts: 51
|
Ahhh, I didn't catch that. I will try that and see where I get. Thanks!
|
|