Scrolling Child Groups question

5 posts, 1 answers
  1. Dan
    Dan avatar
    739 posts
    Member since:
    Mar 2009

    Posted 08 May 2008 Link to this post

    If you are using a PanelBar with Scrolling child groups like this example, is it possible to get the selected item to scroll back into view if the page does a PostBack?

    --
    Stuart
  2. Rosi
    Admin
    Rosi avatar
    2529 posts

    Posted 12 May 2008 Link to this post

    Hello Stuart ,

    I suggest that you try to achieve your goal at the client-side by using the following JS function in the panelbar's OnClientLoad event.

    <form id="form1" runat="server">  
    <script type="text/javascript">  
    function FocusItem()  
    {  
        setTimeout(     
        function()     
        {     
            var panelbar1 = <%=RadPanelbar1.ClientID %> 
            var myitem = panelbar1.get_selectedItem();  
            for (var i=0; i<panelbar1.get_allItems().length; i++)  
            {  
                if (panelbar1.get_allItems()[i].set_selected(true))  
                {  
                    myitem.get_linkElement().scrollIntoView(true);  
                }  
            }  
        }, 100);    
    }  
    </script> 
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px" EnableAJAX="false">  
            <telerik:RadPanelbar ID="RadPanelbar1" runat="server" OnItemClick="RadPanelbar1_ItemClick" Height="300px" Width="200px" ExpandMode="FullExpandedItem" OnClientLoad="FocusItem">  
                <Items> 
                    <telerik:RadPanelItem runat="server" Text="Root Option 1">  
                    </telerik:RadPanelItem> 
                    <telerik:RadPanelItem runat="server" Text="Root Option 2">  
                    </telerik:RadPanelItem> 
                </Items> 
            </telerik:RadPanelbar> 
        </telerik:RadAjaxPanel> 
    </form> 



    Regards,
    Rosi
    the Telerik team
    Instantly find answers to your questions at the new Telerik Support Center
  3. Dan
    Dan avatar
    739 posts
    Member since:
    Mar 2009

    Posted 12 May 2008 Link to this post

    Rosi,

    Thanks for the reply.

    I'm a little confused by this test ...

      if (panelbar1.get_allItems()[i].set_selected(true)) 

    TBH, I'm a bit confused by the need for the loop too.

    Why couldn't you just say...
    var myitem = panelbar1.get_selectedItem();  
    myitem.get_linkElement().scrollIntoView(true); 

    ?

    --
    Stuart
     
  4. Answer
    Rosi
    Admin
    Rosi avatar
    2529 posts

    Posted 12 May 2008 Link to this post

    Hello Stuart,


    I am sorry about this mistake.The line should be:
    panelbar1.get_allItems()[i].get_selected() =true
     
    Also,you are absolutely right that the code I sent you is redundant.

    You can modify it like this:
        <script type="text/javascript">  
        function FocusItem(sender,e)  
        {   
            setTimeout(        
                function()        
                {        
            var panelbar1 = $find('<%=RadPanelBar1.ClientID %>');    
            var myitem = panelbar1.get_selectedItem();     
                if(myitem)  
                    myitem.get_linkElement().scrollIntoView(true);     
                  
            }, 100);  
        }  
        </script> 


    Regards,
    Rosi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Dan
    Dan avatar
    739 posts
    Member since:
    Mar 2009

    Posted 12 May 2008 Link to this post

    Thanks Rosi,

    that's great.

    --
    Stuart
Back to Top