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

itemcommand to not do async postback

5 Answers 303 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 25 Aug 2008, 01:51 AM
Hi

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?

5 Answers, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 25 Aug 2008, 03:25 AM
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:

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    <script type="text/javascript"
        function RadGrid1_Command(sender, args) { 
            var commandName = args.get_commandName(); 
            if (commandName == "GridButton") { 
                $find('<%= RadAjaxManager1.ClientID %>').set_enableAJAX(false); 
            }                
        } 
    </script> 
</telerik:RadScriptBlock> 
 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"  
    DefaultLoadingPanelID="RadAjaxLoadingPanel1"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadGrid1"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings>          
</telerik:RadAjaxManager> 
 
<telerik:RadGrid ID="RadGrid1" runat="server" 
    AllowPaging="true" 
    PageSize="3" 
    OnNeedDataSource="RadGrid1_NeedDataSource"
    <MasterTableView> 
        <Columns> 
            <telerik:GridButtonColumn Text="Push Me!" 
                CommandName="GridButton" /> 
        </Columns> 
    </MasterTableView> 
    <ClientSettings> 
        <ClientEvents OnCommand="RadGrid1_Command" /> 
    </ClientSettings> 
</telerik:RadGrid> 


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

Sincerely,
Kevin Babcock
0
Michael
Top achievements
Rank 1
answered on 05 Sep 2008, 02:29 AM
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?
0
Michael
Top achievements
Rank 1
answered on 05 Sep 2008, 03:39 AM
It also affects tables with DetailTables in them from working properly :(

I can not expand a DetailTable when I implement this solution...
0
Sebastian
Telerik team
answered on 05 Sep 2008, 06:51 AM
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:

http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html

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,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kiresh
Top achievements
Rank 1
answered on 03 Apr 2013, 05:06 AM
Hi Kevin

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


Thanks
Tags
Ajax
Asked by
Michael
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Sebastian
Telerik team
Kiresh
Top achievements
Rank 1
Share this question
or