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

PanelBar Web Part Javascript Issues

1 Answer 41 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 26 Jan 2010, 08:00 PM
Hi,

I've created a SharePoint web part for WSS 3.0 that displays a panel bar similar to one i created in an aspx page.  The problem I'm having is that after I've registered a client script block, the script I was using previously to capture what panel was selected, and then close all the others no longer works.  Previously I had the script triggered using OnClientItemClicked on the client side in the aspx page.  Since web parts are only server side, I've added an attribute to the RadPanelbar of onclick to trigger the script below.  Does anyone know why the script below doesn't work?
<script> 
    function onclick(sender, args) {  
        var selectedtext = args.get_item().get_text();  
          
        var panelBar = $find("<%= RadPanelBar1.ClientID %>");  
        //close all other panels when item is clicked  
        var panelItem = panelBar.findItemByText("panel1");  
        panelItem.collapse();  
        panelItem.blur();  
      
        panelItem = panelBar.findItemByText("panel2");  
        panelItem.collapse();  
        panelItem.blur();  
          
        panelItem = panelBar.findItemByText("panel3");  
        panelItem.collapse();  
        panelItem.blur();  
          
        panelItem = panelBar.findItemByText("panel4");  
        panelItem.collapse();  
        panelItem.blur();  
                  
        panelItem = panelBar.findItemByText(selectedtext);  
        panelItem.expand();  
        panelItem.focus();  
        }                         
</script> 
 
Thanks!

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 28 Jan 2010, 02:43 PM
Hello Mike,

I already replied to your ticket:


I look through your code and noticed that you are doing this:

RadPanelBar1.Attributes.Add("onclick", String.Format("javascript: getControls('"+controlID+"')"));

which is not the proper way to subscribe to the item click of a panelbar item. You need to use the
OnClientItemClicked property.

You can try this code:

RadPanelBar1.OnClientItemClicked = "(function(sender, e){ getControls('" + controlID + "'); })";

Is that what you need?

Kind regards,
Veskoni
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
PanelBar
Asked by
Mike
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or