This is a migrated thread and some comments may be shown as answers.

Scrolling Child Groups question

4 Answers 117 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 08 May 2008, 03:48 PM
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

4 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 12 May 2008, 08:19 AM
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
0
Dan
Top achievements
Rank 1
answered on 12 May 2008, 08:35 AM
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
 
0
Accepted
Rosi
Telerik team
answered on 12 May 2008, 01:21 PM
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
0
Dan
Top achievements
Rank 1
answered on 12 May 2008, 01:25 PM
Thanks Rosi,

that's great.

--
Stuart
Tags
PanelBar
Asked by
Dan
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Dan
Top achievements
Rank 1
Share this question
or