Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Programatically Select Item
posted

I'm trying out the WebExplorerBar as a replacement for the old UltraWebListBar, which failed to support a few browsers (chrome, safari, pc&mac). Naturally, I want the WebExplorerBar to behave in a similar manner to the UltraWebListBar (while being crossbrowser compatible), but so far I haven't had much luck replacating the same behaviour.

I'm using a masterpage, and don't want to use an IFrame/target. The way it should work is that, on page postback, I programatically tell the WebExplorerBar which item is selected, and it will open that group, and select that item.

First, it was rather difficult to specify which item I wanted. With UltraWebListBar, I could specify the selecteditem by:

NavBar.SelectedItem = NavBar.Groups.FromKey(groupkey).Items.FromKey(itemkey) 

Which no longer works, since "SelectedItem" is readonly, and there are no longer item/group collection keys. The only thing I could do was iterate through the groups and items until I found the NavigateURL that matched the current URL, and set that item's selected property to True:

       For Each grp In WebExplorerBar1.Groups
            Dim grpSelected As Boolean = False
            For Each itm As Infragistics.Web.UI.NavigationControls.ExplorerBarItem In grp.Items
                If Request.CurrentExecutionFilePath() = ResolveUrl(itm.NavigateUrl) Then
                    itm.Selected = True
                    grpSelected = True
                    Exit For
                End If
            Next
            If grpSelected Then
                grp.Expanded = True
                Exit For
            End If
        Next

This code executes but apparently does nothing, or is ignored. Upon postback, the WebExplorerBar returns to its initial state, with the first group expanded and nothing visibly selected.

Changing the ViewState on the WebExplorerBar did not help.

What am I doing wrong?

Thanks.

Parents
  • 110
    posted

    I am having similar issues...

    I am trying to set a certain group to be selected on the page_load event.

    PsuedoCode:

     

     

    Dim FindGroup As ExplorerBarGroup

     FindGroup = (From g In WebExplorerBar1.Groups _
                        Where g.Value = Request("GroupID") _
                        Select g).First

    FindGroup.Selected = True
    FindGroup.Expanded = True

    -----

    The group is highlighted properly but when the page load you can see it expand and then close back up and the first group is expanded. The exand triangle is even pointing up like the selected group is expanded but when you mouse over it, it changes back.

    some of the HTML on the aspx page is:

     

    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <ig:WebExplorerBar ID="WebExplorerBar1" runat="server" GroupContentsHeight="" GroupExpandBehavior="SingleExpanded" Width="100%" AnimationEquationType="Bounce" MaxGroupHeight="450px" StyleSetName="RedPlanet">

    -----

    so somewhere the first group is being set to selected or something, even though the first group is explictily set to NOT selected :
    <ig:ExplorerBarGroup GroupContentsHeight="" Text="Home" Selected="false" Value="mi6home">

    so I dont think its you doing something wrong, I feel it is the control is automatically selecting the first group. I even tried adding the following lines before I selected the group I wanted:
            WebExplorerBar1.Groups(WebExplorerBar1.SelectedItem.Index).Expanded = False
            WebExplorerBar1.Groups(WebExplorerBar1.SelectedItem.Index).Selected = False

    but those caused an exception as .SelectedItem was Nothing (unless I set Selected="true" on one of the groups in the HTML), and even if I selected one of the groups, it unselected it but still same "NON" results of the group highlighted but not expnaded and the wrong group expanded.

    Thanks,

     

Reply Children