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

[Solved] Conditional clientside postback with templated column

1 Answer 163 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 01 Jul 2008, 11:18 AM
Hi,

I have a grid that contains a templated column containing a RadToolbar.  The Toolbar contains one or more buttons and a dropdown list of additional options.  Currently I am doing a postback on row click and performing an ajax call to update a panel.  Everything works fine except when I try to click the dropdown list in my toolbar in the grid.  It is performing the postback which is killing the dropdown open.  It never displays.  If I click the other toolbar buttons then the postback does not fire.  How can I get the dropdown options to display and suppress the postback/selection?  Can I add conditional logic on the client side that will suppresss the postback if they are clicking a particular cell of my column containing my toolbar?   I'm not sure how to do that.

thanks

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 01 Jul 2008, 11:30 AM
Hello Randy,

First, please check if your case is related to this KB article:
How to use RadToolBar dropdown button with file output 

Otherwise, there are two ways to  prevent a specific button from performing postback.

You can set the PostBack property to false for the item for which you want to prevent postback:

<Items> 
       <telerik:RadToolBarButton runat="server" Text="Button A">  
       </telerik:RadToolBarButton> 
       <telerik:RadToolBarButton runat="server" PostBack="false" Text="Button B (no postback)">  
       </telerik:RadToolBarButton> 
       <telerik:RadToolBarButton runat="server" Text="Button C">  
       </telerik:RadToolBarButton> 
   </Items>  

Or, you can cancel the OnClientButtonClicking event for the specific item:

<telerik:RadToolBar ID="RadToolbar1" runat="server" 
       OnButtonClick="RadToolbar1_ButtonClick" 
       OnClientButtonClicking="OnClientButtonClickingHandler">  
      <Items> 
           <telerik:RadToolBarButton runat="server" Text="Button A">  
           </telerik:RadToolBarButton> 
           <telerik:RadToolBarButton runat="server" Value="noPostback" Text="Button B (no postback)">  
           </telerik:RadToolBarButton> 
           <telerik:RadToolBarButton runat="server" Text="Button C">  
           </telerik:RadToolBarButton> 
       </Items> 
   </telerik:RadToolBar> 
   <script type="text/javascript">  
   function OnClientButtonClickingHandler(sender, eventArgs)  
   {  
        if(eventArgs.get_item().get_value()=="noPostback")  
        {  
           eventArgs.set_cancel(true);  
        }  
   }  
   </script>  

Let us know how it goes.

Regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Randy
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or