Welcome Guest Search | Active Topics | Sign In | Register

Data Binding Options
RGWD
Posted: Monday, October 22, 2007 8:50:38 AM
Rank: Newbie
Groups: Member

Joined: 10/16/2007
Posts: 5
Hello,

Not sure what I'm doing wrong - trying to programatically data bind to a menu. The text is coming through, but I can't seem to change other parameters. A second, related question is: How do I make a menuitem non-selectable?


Code: Visual Basic.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 Dim mainDs As DataSet = CreateDataSet()


        eomnuMain.DataSource = mainDs
        eomnuMain.DataFields = "ID|ParentID|Name|Value|Disabled|Separator|LookID|SideImage"
       


        Dim bindingDisabled As New EO.Web.DataBinding()
        bindingDisabled.DataField = "Disabled"
        bindingDisabled.Property = "RaisesServerEvent "
        eomnuMain.Bindings.Add(bindingDisabled)

        Dim bindingSeparator As New EO.Web.DataBinding()
        bindingSeparator.DataField = "Separator"
        bindingSeparator.Property = "IsSeparator"
        eomnuMain.Bindings.Add(bindingSeparator)

        Dim bindingLookID As New EO.Web.DataBinding()
        bindingLookID.DataField = "LookID"
        bindingLookID.Property = "LookID"
        eomnuMain.Bindings.Add(bindingLookID)

        Dim bindingSideImage As New EO.Web.DataBinding()
        bindingSideImage.DataField = "SideImage"
        bindingSideImage.Property = "SideImage"
        eomnuMain.Bindings.Add(bindingSideImage)

        Dim binding As New EO.Web.DataBinding()
        binding.DataField = "Name"
        binding.Property = "Text-Html"
        eomnuMain.Bindings.Add(binding)

        ' Populate from the data source (mainTable);
        eomnuMain.DataBind()


        Me.GVMenu.DataSource = mainDs.Tables("Main")
        GVMenu.DataBind()
    End Sub

   
    Private Function CreateDataSet() As DataSet
        'Define a DataSet
        Dim ds As New DataSet()

        'Get Data from MasterAssignments
        Dim dsMasterAssign As DataSet = CreateAssignmentMaster()

        'check for empty menu
        Dim blnCurrent As Boolean = False
        Dim blnCompleted As Boolean = False
        Dim blnLibrary As Boolean = False

        Dim x, y As Integer

        'Create the DataTable object
        Dim table As DataTable = ds.Tables.Add("Main")
        Dim menuID As DataColumn = table.Columns.Add("ID", GetType(Integer))
        Dim menuparentID As DataColumn = table.Columns.Add("ParentID", GetType(Integer))
        Dim menuName As DataColumn = table.Columns.Add("Name", GetType(String))
        Dim menuValue As DataColumn = table.Columns.Add("Value", GetType(String))
        Dim menuSelectable As DataColumn = table.Columns.Add("Disabled", GetType(Boolean))
        Dim menuSeparator As DataColumn = table.Columns.Add("Separator", GetType(Boolean))
        Dim menuLookID As DataColumn = table.Columns.Add("LookID", GetType(String))
        Dim menuSideImage As DataColumn = table.Columns.Add("SideImage", GetType(String))
        table.Rows.Add(New Object() {1, Nothing, "Main", "Main", 0, 1, "_TopLevelItem"})
        table.Rows.Add(New Object() {2, 1, "Email", "Email", 1, 0, "_Default"})
        table.Rows.Add(New Object() {3, 1, "Logout", "Logout", 1, 0, "_Default"})


        table.Rows.Add(New Object() {1000, Nothing, Nothing, "Separator", 0, 1, "_Separator", Nothing})



        'Define relations
        Dim r As DataRelation = ds.Relations.Add(menuID, menuparentID)
        r.Nested = True

        Return ds
    End Function




Code: HTML/ASPX
<eo:Menu ID="eomnuMain" runat="server" CssFile="~/MasterStyleSheet.css" RaisesServerEvent="True" Style="position: relative" Width="800px">
       
        <LookItems>
        
            <eo:MenuItem ItemID="_TopGroup">
                <SubMenu ItemSpacing="3" LeftIconCellWidth="25" SideImage="OfficeXPSideBar" Style-CssText="background-color:#2f3451;border-bottom-color:white;border-bottom-style:solid;border-bottom-width:5px;border-left-color:white;border-left-style:solid;border-left-width:5px;border-right-color:white;border-right-style:solid;border-right-width:5px;border-top-color:white;border-top-style:solid;border-top-width:5px;color:white;cursor:hand;font-family:skia;font-size:10pt;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;">
                </SubMenu>
            </eo:MenuItem>
            
            <eo:MenuItem ItemID="_TopLevelItem" 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;"
                 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" 
                    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 ItemID="_Separator" Image-Padding-All="3" Image-Padding-Bottom="3" Image-Padding-Left="3"
                Image-Padding-Right="3" Image-Padding-Top="3" IsSeparator="True" 
                NormalStyle-CssText="border-right: #6e7d8d 1px solid; border-top: #abc3dc 1px solid; margin: 2px; border-left: #abc3dc 1px solid; width: 1px; border-bottom: #6e7d8d 1px solid; height: 1px">
            </eo:MenuItem>
            
            <eo:MenuItem ItemID="_Default" 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;"
                 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>
      
    </eo:Menu>
eo_support
Posted: Monday, October 22, 2007 10:04:33 AM
Rank: Administration
Groups: Administration

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

DataField property is wrong. That property is used to specify the key information. So if you specify 3 fields there, the menu will try to populate 3 levels. Obviously you don't have that many levels. You probably only want "ID|ParentID".

The Property value for Most of your DataBinding objects is also wrong. The value is not always the same as the name of the Property, and some properties are not supported. To find out which one is supported and the correct value, use Menu Builder to create the DataBinding object.

A menu is always "clickable" unless it is disabled. The difference is what you do after it is clicked. Clicking a menu does nothing if RaisesServerEvent if false and NavigateUrl is empty. However you may wish to give such items different styles --- for example, grayed out styles. In that case you would set DisabledStyle and also set the menu item's Disabled to true.

Thanks
RGWD
Posted: Monday, October 22, 2007 6:39:53 PM
Rank: Newbie
Groups: Member

Joined: 10/16/2007
Posts: 5
Thank you, that clarified things quite a bit.

I'm still in need of a solution for the following situation though.

My entire menu is generated through code behind.

I'd like to have the TopGroup's RaisesServerEvent set to false to prevent clicking, but when I do this, my entire menu does not respond (i.e. clicking on an item from the drop down does not raise an event).

If I disable an item from the top group, it will not drop down the menu on a hover over.

I can check the value of the item after it's selected, but I'm trying to avoid the postback altogether.

Can I set up the menu so that only the top level does not raise an event, and yet the lower levels will?
eo_support
Posted: Monday, October 22, 2007 6:45:48 PM
Rank: Administration
Groups: Administration

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

The way RaisesServerEvent works is that each child item uses the value of its parent item as default value. So if you have:

Parent = false;
Child = not set;

Then "Child" will take a value of "false". In order for the child item to take value true, you must explicitly set it.

Parent = false;
Child = true;

The easiest way for you to do this is to handle ItemDataBound event. Inside that event you can do:

Code: C#
if (e.MenuItem.Level == 0)
    e.MenuItem.RaisesServerEvent = false;
else
    e.MenuItem.RaisesServerEvent = true;


Thanks
RGWD
Posted: Monday, October 22, 2007 7:02:46 PM
Rank: Newbie
Groups: Member

Joined: 10/16/2007
Posts: 5
Almost there...

I now get the error

Value of type 'Boolean' cannot be converted to 'EO.Web.NullableBool'.

Thanks for the help...

RGWD
eo_support
Posted: Monday, October 22, 2007 7:11:31 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Ah. Do e.MenuItem.RaisesServerEvent = EO.Web.NullableBool.True. Sorry about that.
RGWD
Posted: Monday, October 22, 2007 7:37:19 PM
Rank: Newbie
Groups: Member

Joined: 10/16/2007
Posts: 5
That did it!

Thanks for the help,

RGWD


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.