itemcommand to not do async postback

6 posts, 0 answers
  1. Michael
    Michael avatar
    84 posts
    Member since:
    May 2008

    Posted 24 Aug 2008 Link to this post


    I have a RadGrid with AjaxManager attached to it, also sometimes a RadAjaxPanel.

    However I want a gridbuttoncolumn to NOT postback asynchronously.

    How can I do this?
  2. Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 24 Aug 2008 Link to this post

    Hello Michael,

    You can intercept the Grid's OnCommand client-side event when the particular button is clicked, then set the EnableAJAX property of your RadScriptManager to false. This will allow the button to cause a full post back, but maintain partial-page post backs for all other Grid command events.

    Here is a quick example:

    1 <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    2     <script type="text/javascript"
    3         function RadGrid1_Command(sender, args) { 
    4             var commandName = args.get_commandName(); 
    5             if (commandName == "GridButton") { 
    6                 $find('<%= RadAjaxManager1.ClientID %>').set_enableAJAX(false); 
    7             }                
    8         } 
    9     </script> 
    10 </telerik:RadScriptBlock> 
    12 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"  
    13     DefaultLoadingPanelID="RadAjaxLoadingPanel1"
    14     <AjaxSettings> 
    15         <telerik:AjaxSetting AjaxControlID="RadGrid1"
    16             <UpdatedControls> 
    17                 <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
    18             </UpdatedControls> 
    19         </telerik:AjaxSetting> 
    20     </AjaxSettings>          
    21 </telerik:RadAjaxManager> 
    23 <telerik:RadGrid ID="RadGrid1" runat="server" 
    24     AllowPaging="true" 
    25     PageSize="3" 
    26     OnNeedDataSource="RadGrid1_NeedDataSource"
    27     <MasterTableView> 
    28         <Columns> 
    29             <telerik:GridButtonColumn Text="Push Me!" 
    30                 CommandName="GridButton" /> 
    31         </Columns> 
    32     </MasterTableView> 
    33     <ClientSettings> 
    34         <ClientEvents OnCommand="RadGrid1_Command" /> 
    35     </ClientSettings> 
    36 </telerik:RadGrid> 

    I hope this helps. If you have any further questions, please don't hesitate to ask.

    Kevin Babcock
  3. Michael
    Michael avatar
    84 posts
    Member since:
    May 2008

    Posted 04 Sep 2008 Link to this post

    Thanks Kevin

    I couldn't manage to get it working on 1 of my pages, but got it working on another page. However the PrimaryKey of the radgrid item clicked always defaults to the first item in the RadGrid. When I set enableAjax=false in the radajaxmanager it worked and got the correct PrimaryKey.

    Do you know why this is happening?
  4. Michael
    Michael avatar
    84 posts
    Member since:
    May 2008

    Posted 04 Sep 2008 Link to this post

    It also affects tables with DetailTables in them from working properly :(

    I can not expand a DetailTable when I implement this solution...
  5. Sebastian
    Sebastian avatar
    9934 posts

    Posted 05 Sep 2008 Link to this post

    Hi Michael,

    Is it possible that you generate your grid or its columns programmatically? If so, note that you need to do that in par with the concepts outlined in this article from the documentation:

    This should ensure that the viewstate of the control will remain consistent and its lifecycle will be intact. If the issue seems to be elsewhere, paste your grid definition along with the relevant code-behind logic in this forum post. Thus we will familiarize with your implementation and will advice you further.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Kiresh
    Kiresh avatar
    24 posts
    Member since:
    Sep 2012

    Posted 03 Apr 2013 Link to this post

    Hi Kevin

    i tried your code but shows me this error
    Microsoft JScript runtime error: Object doesn't support property or method 'get_commandName'

Back to Top