Welcome Guest Search | Active Topics | Sign In | Register

Disable Sub Menu Items based on callback from parent item click Options
Sean Clark
Posted: Friday, September 9, 2011 11:39:23 AM
Rank: Advanced Member
Groups: Member

Joined: 12/24/2008
Posts: 43
Hi

I have a couple of sub menu items that I would like to enable/disable based on decisions made during the server side click event of the parent menu. The submen items are disabled by default

I have not been succesful and have tried the following:

OnGroupExpand clientside to execute a callback to set the submenu item disabled state.
Server side click event of the parent menu item calls code to set the submenu item disabled state.
Callback panel around the menu.

All I can achieve is that either the menu items remain disabled even though their server side disabled=false property is set or that the postback prevents the sub menu from staying open.

Should this be possible?

Code: HTML/ASPX
<%@ Register TagPrefix="eo" Namespace="EO.Web" Assembly="EO.Web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
<script type="text/javascript">
    function GroupExpand(e, eventInfo) {
        if (eventInfo.getItem().getItemId() == "MENU1")
            CheckPermissions();
    }

    function CheckPermissions() {
        eo_Callback('EO_Callback_Toolbar', '');
    }

</script>

<eo:Callback runat="server" ID="EO_Callback_CheckSchedulePermissions" 
            onexecute="EO_Callback_CheckSchedulePermissions_Execute"></eo:Callback>

<eo:CallbackPanel runat="server" ID="EO_Callback_Toolbar" onexecute="EO_Callback_Toolbar_Execute" ChildrenAsTriggers="true">

        <eo:Menu runat="server" ID="EOMenu" CheckIconUrl="OfficeCheckIcon" 
            ControlSkinID="None" Width="200px" ClientSideOnGroupExpand="" 
            onitemclick="EOMenu_ItemClick" ExpandOnClick="EnabledAlways">
            <LookItems>
                <eo:MenuItem DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:5px;padding-right:5px;padding-top:1px;color:lightgrey" 
                    Height="24" 
                    HoverStyle-CssText="background-color:#c1d2ee;border-bottom-color:#316ac5;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#316ac5;border-left-style:solid;border-left-width:1px;border-right-color:#316ac5;border-right-style:solid;border-right-width:1px;border-top-color:#316ac5;border-top-style:solid;border-top-width:1px;padding-left:4px;padding-right:4px;padding-top:0px;padding-bottom:0px;" 
                    ItemID="_TopLevelItem" 
                    NormalStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:5px;padding-right:5px;padding-top:1px;" 
                    SelectedStyle-CssText="background-color:white;border-bottom-color:#316ac5;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#316ac5;border-left-style:solid;border-left-width:1px;border-right-color:#316ac5;border-right-style:solid;border-right-width:1px;border-top-color:#316ac5;border-top-style:solid;border-top-width:1px;padding-left:4px;padding-right:4px;padding-top:0px;padding-bottom:0px;">
                    <SubMenu CollapseEffect-Duration="150" CollapseEffect-Type="Fade" 
                        ExpandEffect-Duration="150" ExpandEffect-Type="Fade" ItemSpacing="3" 
                        LeftIconCellWidth="25" SideImage="OfficeXPSideBar" 
                        Style-CssText="background-color:#fcfcf9;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;">
                    </SubMenu>
                </eo:MenuItem>
                <eo:MenuItem IsSeparator="True" ItemID="_Separator" 
                    NormalStyle-CssText="background-color:#c5c2b8;height:1px;margin-left:30px;width:1px;">
                </eo:MenuItem>
                <eo:MenuItem DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:5px;padding-top:1px;color:lightgrey" 
                    Height="24" 
                    HoverStyle-CssText="background-color:#c1d2ee;border-bottom-color:#316ac5;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#316ac5;border-left-style:solid;border-left-width:1px;border-right-color:#316ac5;border-right-style:solid;border-right-width:1px;border-top-color:#316ac5;border-top-style:solid;border-top-width:1px;padding-left:1px;padding-right:4px;padding-top:0px;" 
                    ItemID="_Default" 
                    NormalStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:5px;padding-top:1px;" 
                    SelectedStyle-CssText="background-color:white;border-bottom-color:#316ac5;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#316ac5;border-left-style:solid;border-left-width:1px;border-right-color:#316ac5;border-right-style:solid;border-right-width:1px;border-top-color:#316ac5;border-top-style:solid;border-top-width:1px;padding-left:1px;padding-right:4px;padding-top:0px;" 
                    Text-Padding-Right="30">
                    <SubMenu CollapseEffect-Duration="150" CollapseEffect-Type="Fade" 
                        ExpandEffect-Duration="150" ExpandEffect-Type="Fade" ItemSpacing="3" 
                        LeftIconCellWidth="25" SideImage="OfficeXPSideBar" 
                        Style-CssText="background-color:#fcfcf9;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;">
                    </SubMenu>
                </eo:MenuItem>
            </LookItems>
            <TopGroup>
                <Items>
                    <eo:MenuItem ItemID="MENU1" Text-Html="Menu Item 1" RaisesServerEvent="True">
                        <SubMenu>
                            <Items>
                                <eo:MenuItem Disabled="True" ItemID="SUBMENU1.1" Text-Html="Sub Menu Item 1.1">
                                </eo:MenuItem>
                                <eo:MenuItem Disabled="True" ItemID="SUBMENU1.2" Text-Html="Sub Menu Item 1.2">
                                </eo:MenuItem>
                            </Items>
                        </SubMenu>
                    </eo:MenuItem>
                </Items>
            </TopGroup>
        </eo:Menu>    
    </eo:CallbackPanel>
    </div>
    </form>
</body>
</html>


Code: C#
public partial class WebForm1 : System.Web.UI.Page
    {

        protected EO.Web.Menu EO_Menu;

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void EO_Callback_CheckSchedulePermissions_Execute(object sender, EO.Web.CallbackEventArgs e)
        {
            EOMenu.FindItem("MENU1/SUBMENU1.1").Disabled = false;
            EOMenu.FindItem("MENU1/SUBMENU1.2").Disabled = false;
        }

        protected void EO_Callback_Toolbar_Execute(object sender, EO.Web.CallbackEventArgs e)
        {
            EOMenu.FindItem("MENU1/SUBMENU1.1").Disabled = false;
            EOMenu.FindItem("MENU1/SUBMENU1.2").Disabled = false;
            EO_Callback_Toolbar.Update();
        }

        protected void EOMenu_ItemClick(object sender, EO.Web.NavigationItemEventArgs e)
        {
            if (e.MenuItem.ItemID == "SUBMENU1.1")
            {
                EOMenu.FindItem("MENU1/SUBMENU1.1").Disabled = false;
                EOMenu.FindItem("MENU1/SUBMENU1.2").Disabled = false;
            }
        }
    }
eo_support
Posted: Friday, September 9, 2011 2:03:52 PM
Rank: Administration
Groups: Administration

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

I do not believe there is a workable solution for you to dynamically update the menu from server side while user is navigating the menu. The update needs to occur instantly so they only viable solution is to update them on the client side via JavaScript. In your case, the sub menu expands immediately after triggering the callback, however at that point the callback has not completed yet. So the sub menu item enabled status has not been updated at that point.

Thanks


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.