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

[Solved] Ajax/onRequest/on client - ItemCommand

4 Answers 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sunny
Top achievements
Rank 1
Sunny asked on 12 Jun 2010, 01:31 PM
  • Hello,

    I have posted my issue- when I make use of client side item command in radgrid, the server side item command doesn't retrieve item datakey or the index or the item number as well. I wanted to give file download functionality on grid's specified command. So I wanted AJAX to be disabled at certain control's request...Please review the following conversation I had earlier but didn't got the proper answer.

    It would be great if I can see some specific example as well on this

    Thanks,
    Sunny

    _______________________________________________________________________________
    hello

    I need to disable AJAX on RadGrid's one command for file download purpose and so I, first, made use of client settings and there used onCommand client side where I make AJAX disabled which works fine at its part
    So the flow goes first at client side and first enables/disables AJAX and then goes server side on ItemCommand event where I can not access e.Item's values and even data key value

    Please refer to my code snippet for server side event-ItemCommand:

    GridEditableItem editedItem = e.Item as GridEditableItem; 
    Hashtable newValues = new Hashtable(); 
    editedItem.ExtractValues(newValues); 

    Edit your postReply

  • Telerik Adminadmin's avatar

    Posted on May 24, 2010 (permalink)

    Hi Sunny,

    One possible option in this case would be to not use the onCommand client side handler, but rather use the onrequest start client side event for the ajax control

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

    Give this suggestion a try and let me know how it goes.

    Greetings,
    Yavor 
    the Telerik team
  • Could you please give me a proper example of ragdrid having Item Command and onStartRequest integrated?

4 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 16 Jun 2010, 03:14 PM
Hi Sunny,

As I am not sure what is your RadGrid implementation, I will describe a scenario that is tested and works.

In a GridTemplateColumn, you put the control which will trigger the download. Then you handle the OnRequestStart client event of the AJAX control you are using, and check in the javascript function if a control from the template column started the request. If so, you disable AJAX. After doing so you will be able to access the indices and values in the ItemCommand handler in the code-behind.

Let's say you have a GridTemplateColumn with a Button which triggers the download:
<telerik:GridTemplateColumn>
        <ItemTemplate>
            <asp:Button ID="btnStartDownload" runat="server" 
            CommandName="Download" Text="Download" />
        </ItemTemplate>
</telerik:GridTemplateColumn>

And, for example the RadGrid is in an RadAjaxPanel:
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="onRequestStart" LoadingPanelID="RadAjaxLoadingPanelSite">
<%-- RadGrid implementation --%>
</telerik:RadAjaxPanel>

Here is the javascript function:

function onRequestStart(sender, eventArgs) {
        if (eventArgs.get_eventTarget().indexOf("btnStartDownload") != -1) {            
            eventArgs.set_enableAjax(false);
        }
}

I believe this will solve your issue.

Regards,
Tsvetina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Christian
Top achievements
Rank 1
answered on 30 Apr 2013, 10:59 PM
OK its works, but After download my File is necessary start again the Ajax ?

Regards
Christian
0
Christian
Top achievements
Rank 1
answered on 30 Apr 2013, 10:59 PM
OK its works, but After download my File is necessary start again the Ajax ?

Regards
Christian
0
Eyup
Telerik team
answered on 03 May 2013, 08:32 AM
Hi Christian,

You won't need to enable back the ajaxification since the suggested approach handles only the current event case. For additional information about downloading and uploading with ajaxified controls, you can check out the following article:
http://www.telerik.com/help/aspnet-ajax/upload-uploading-ajax.html

Hope this helps.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Sunny
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Christian
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or