Rad Panelbar & Item Click

7 posts, 1 answers
  1. kollam2003
    kollam2003 avatar
    86 posts
    Member since:
    Nov 2006

    Posted 06 Apr 2009 Link to this post

    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); 

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Apr 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shireesha
    shireesha avatar
    1 posts
    Member since:
    Oct 2010

    Posted 25 Oct 2010 Link to this post

    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.
  5. Edward
    Edward avatar
    3 posts
    Member since:
    Nov 2010

    Posted 26 Jan 2011 Link to this post

    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?
  6. Edward
    Edward avatar
    3 posts
    Member since:
    Nov 2010

    Posted 26 Jan 2011 Link to this post

    Fixed. One of our programmers added a serverside event handler to handle the click.
  7. CONSTELLATION
    CONSTELLATION  avatar
    1 posts
    Member since:
    Oct 2012

    Posted 28 Jul 2014 in reply to Edward Link to this post

    Can you provide the solution ? 
  8. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Jul 2014 in reply to CONSTELLATION Link to this post

    Hi,

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

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017