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

Rad Panelbar & Item Click

6 Answers 288 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
kollam2003
Top achievements
Rank 1
kollam2003 asked on 06 Apr 2009, 07:20 AM

I have a rad panel bar.
In its item click i want the selected value.

I'm binding the panel bar using:

RadPanelBar_MenuLeft.DataSource = _dtFunctions;  
            RadPanelBar_MenuLeft.DataFieldID = "FunctionID";  
            RadPanelBar_MenuLeft.DataTextField = "FunctionName";  
            RadPanelBar_MenuLeft.DataValueField = "FunctionID";  
            RadPanelBar_MenuLeft.DataNavigateUrlField = "PageName";  
            RadPanelBar_MenuLeft.DataBind();  

private void RadPanelBar_MenuLeft_ItemClick(object sender, Telerik.Web.UI.RadPanelBarEventArgs e)  
    {  
        if (e.Item.Items.Count > 0)  
        {  
            if (e.Item.Expanded == false)  
            {  
                _Val = "Collapsed panel item - " + e.Item.Value;  
            }  
           else  
            {  
                _Val = "Expanded panel item - " + e.Item.Value;  
            }  
        }  
        else  
        {  
             _Val = "Clicked panel item - " + e.Item.Value;  
       }  
    } 
 
 
 
 
The Panel item click will work if the DataNavigateUrlField is not given. 
How to get the selected items value even if the DataNavigateUrlField is given. 
Plz help  




and on init
this.RadPanelBar_MenuLeft.ItemClick += new Telerik.Web.UI.RadPanelBarEventHandler(this.RadPanelBar_MenuLeft_ItemClick); 

6 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 07 Apr 2009, 10:58 AM
Hi,

One suggestion is setting custom attribute instead of DataNavigateUrl to the panelbar items and store in it the value of the NavigateUrl, in this case ItemClick is always fired and in its handler you can retrieve the NavigateUrl value and redirect the page manually.

[CS]:
    
protected void Page_Load(object sender, EventArgs e)     
{    
    RadPanelBar_MenuLeft.DataSource = SqlDataSource1;     
    RadPanelBar_MenuLeft.DataFieldID = "FunctionID";     
    RadPanelBar_MenuLeft.DataTextField = "FunctionName";     
    RadPanelBar_MenuLeft.DataValueField = "FunctionID";     
    RadPanelBar_MenuLeft.DataBind();       
}     
 
protected void RadPanelBar_MenuLeft_ItemDataBound(object sender, RadPanelBarEventArgs e)     
{  
    DataRowView dataRow = (DataRowView)e.Item.DataItem;     
    e.Item.Attributes["URL"] = dataRow["PageName"].ToString();     
    e.Item.ToolTip = e.Item.Attributes["URL"];     
}  
 
protected void RadPanelBar_MenuLeft_ItemClick(object sender, RadPanelBarEventArgs e)  
{  
    Response.Write(e.Item.Text); // Clicked item  
    Response.Redirect(e.Item.Attributes["URL"]); // Redirecting the page  

Thanks,
Princy.
0
shireesha
Top achievements
Rank 1
answered on 25 Oct 2010, 07:53 AM
Hello every one,


Im also in the same boat as you people are in ,

I too want to redirect the page to a specified URL on item click in the panel bar my code is as follows ,

Protected Sub RadPanelBar1_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles RadPanelBar1.ItemClick
            If e.Item.Items.Count > 0 Then
                If e.Item.Expanded = False Then
                    Label1.Text = "Collapsed panel item - " + e.Item.Text
                    
                Else
                    Label1.Text = "Expanded panel item - " + e.Item.Text
                End If
            Else
                'Label1.Text = "Clicked panel item - " + e.Item.Text


plz any help appreciated,


Thanks
Shireesha.
0
Edward
Top achievements
Rank 1
answered on 26 Jan 2011, 06:25 PM
I have a different problem. I have a radPanelbar (asp.net.ajax). And my problem is that I can only expand the panel if I click on the arrow icon. But if I click on the bar of the panel and not right on the arrow icon, the control creates a postback and than expands the panel.


<telerik:RadPanelBar runat="server" Width="100%" ID="mypanelbar" ExpandMode="FullExpandedItem"
                                Height="100%">
                                <Items>
                                    <telerik:RadPanelItem Text="Sites" Value="Sites">
                                        <Items>
                                            <telerik:RadPanelItem Value="SiteChild">
                                                <ContentTemplate>
                                                    <telerik:RadMenu runat="server" ID="MyMenuSites" DataTextField="Name" DataFieldID="ID"
                                                        Flow="Vertical" Height="100%" OnItemClick="MyMenuSites_ItemClick" Width="100%"
                                                        Style="z-index2000">
                                                        <DefaultGroupSettings ExpandDirection="Down" Flow="Vertical" />
                                                    </telerik:RadMenu>
                                                </ContentTemplate>
                                            </telerik:RadPanelItem>
                                        </Items>
                                    </telerik:RadPanelItem>
                                    <telerik:RadPanelItem Text="Trends and Graphs" Value="Trends">
                                        <Items>
                                            <telerik:RadPanelItem Value="TrendChild">
                                                <ContentTemplate>
                                                    <telerik:RadMenu runat="server" ID="MyMenuTrends" DataTextField="MenuName" DataFieldID="Level"
                                                        Flow="Vertical" Height="100%" OnItemClick="MyMenuTrends_ItemClick" Width="100%"
                                                        Style="z-index2000">
                                                        <DefaultGroupSettings ExpandDirection="Down" Flow="Vertical" Height="80px" />
                                                    </telerik:RadMenu>
                                                </ContentTemplate>
                                            </telerik:RadPanelItem>
                                        </Items>
                                    </telerik:RadPanelItem>
                                </Items>
                            </telerik:RadPanelBar>

So, what am I doong wrong?
0
Edward
Top achievements
Rank 1
answered on 26 Jan 2011, 06:43 PM
Fixed. One of our programmers added a serverside event handler to handle the click.
0
CONSTELLATION
Top achievements
Rank 1
answered on 28 Jul 2014, 05:51 PM
Can you provide the solution ? 
0
Shinu
Top achievements
Rank 1
answered on 29 Jul 2014, 03:27 AM
Hi,

Try to follow this online demo to achieve your scenario. Please provide your code if it doesn't help.

Thanks,
Shinu.
Tags
PanelBar
Asked by
kollam2003
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
shireesha
Top achievements
Rank 1
Edward
Top achievements
Rank 1
CONSTELLATION
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Share this question
or