This is a migrated thread and some comments may be shown as answers.
detect child item click only not the header
3 Answers 49 Views
This is a migrated thread and some comments may be shown as answers.
appdev
Top achievements
Rank 1
appdev asked on 07 Jul 2009, 04:34 PM
i have this
<telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Web20" Width="198px" Height="550px" ExpandMode="FullExpandedItem"  > 
                        <Items> 
                            <telerik:RadPanelItem  Value="RadPanelBar_CompanyReport" Text="Company Report" > 
                                <Items> 
                                    <telerik:RadPanelItem Value="CompanyReport_PanelBar" > 
                                       <Items> 
then i generate item automatically on the server side. so my question is how do i detect which child items for CompanyReport_Panelbar just got clicked? thank you for your help. using 

Protected

 

Sub RadPanelBar1_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles RadPanelBar1.ItemClick

will detect every single click. i don't want that i want to only postback on the item. i don't want to use navigateurl. is there a way to accomplish this? thanks.

 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 08 Jul 2009, 06:52 AM
Hi Duy,

I guess you want to prevent postback on clicking the panelbar item with value 'CompanyReport_Panelbar'. If so you can attach 'OnClientItemClicking' event to panelbar and try the following client side code.

JavaScript:
 
<script type="text/javascript">  
function OnClientItemClicking(sender, eventArgs)  
{  
    var item = eventArgs.get_item();  
    item.set_expanded(!item.get_expanded()); // expand or collapse  
    if (item.get_value() == 'CompanyReport_PanelBar'// Check whether the clicked item  
    {  
        eventArgs.set_cancel(true); // Cancel the postback  
    }  
    else 
    {  
        eventArgs.set_cancel(false);  
    }  
}  
</script> 

Thanks,
Princy.
0
appdev
Top achievements
Rank 1
answered on 08 Jul 2009, 01:01 PM
if  do what you suggested, it will always go to the else statment it never actually see the CompanyReport_PanelBar but only the RadPanelBar_CompanyReport. then when i change your line of code to:
if (item.get_value() == "RadPanelBar_CompanyReport" ) it will go inside the if. but then how does it post back if that child item in CompanyReport_PanelBar is clicked on? If you allow OnItemClicked, that will just postback on every single click you click on radpanelbar. please help thanks.
0
appdev
Top achievements
Rank 1
answered on 08 Jul 2009, 01:25 PM
i got it.
the code you gave me work fine but just need one change
function OnClientItemClicking(sender, eventArgs)    
        {    
            var item = eventArgs.get_item();    
            item.set_expanded(!item.get_expanded()); // expand or collapse    
            alert(item.get_value());  
            // RadPanelBar_CompanyReport is what it needs to be not CompanyReport_PanelBar
            if (item.get_value() == "RadPanelBar_CompanyReport"// Check whether the clicked item    
            {       
                alert("here");               
                eventArgs.set_cancel(true); // Cancel the postback    
            }    
            else   
            {     
                alert("not");                
                eventArgs.set_cancel(false);    
            }    
        } 
then you must enable OnClientItemClicking="OnClientItemClicking" and OnItemClicked="RadPanelBar1_ItemClick" in order for it to post back. thank you for your help.
Asked by
appdev
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
appdev
Top achievements
Rank 1
Share this question
or