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

Both export and attachment download from AJAX RadGrid

13 Answers 261 Views
Grid
This is a migrated thread and some comments may be shown as answers.
yerlan
Top achievements
Rank 1
yerlan asked on 26 Jul 2010, 10:47 AM

Hello.

I'm found in doc separate examples about exporting and downloading attachments from ajaxified RadGrid.

After Implementing both of them = exporting doesn't work. Is it possible to combine this functions in one grid?

Thanks.

13 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 26 Jul 2010, 03:42 PM
Hello Yerlan,

Possible reason for this behavior is that your export button is ajaxified. Please examine the following link:
Export from ajaxified grid

If this is not the case, please provide a sample code so I can examine your approach.

Regards,
Daniel
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
yerlan
Top achievements
Rank 1
answered on 26 Jul 2010, 04:09 PM

Daniel.

Yes, my radGrid ajaxified, and i'm using solution from you provided link:

1.function onRequestStart(sender, args) {
2.    if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
3.        args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
4.        args.get_eventTarget().indexOf("ExportToPdfButton") >= 0 ||
5.        args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) {
6.        args.set_enableAjax(false);
7.    }
8.}
1.<telerik:RadAjaxManager ID="RadAjaxManager" runat="server">  
2.    <ClientEvents OnRequestStart="onRequestStart"/>      
3.</telerik:RadAjaxManager>
(RadAjaxManager located on masterpage).

Webpage contains RadGrid, ajaxified by RadAjaxManagerProxy.
1.<telerik:RadGrid ID="MyGrid" runat="server">
2.    <ClientSettings AllowColumnsReorder="true" ColumnsReorderMethod="Reorder">            
3.        <Resizing AllowColumnResize="True" ResizeGridOnColumnResize="true"/>
4.        <ClientEvents OnCommand="gridCommand"/>                 
5.    </ClientSettings>       
6.    ...
7.</telerik:RadGrid>
Grid's OnCommand event handled by this code on webpage:

01.<telerik:RadCodeBlock runat="server">
02.<script type="text/javascript">
03.    <!--
04.    function gridCommand(sender, args) {
05.        var a = args.get_commandName();
06.        if (args.get_commandName() == "DownloadAttachment") {
07.            var manager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
08.            manager.set_enableAJAX(false);
09.  
10.            setTimeout(function () {
11.                manager.set_enableAJAX(true);
12.            }, 0);
13.        }
14.    }
15.    -->
16.</script>
17.</telerik:RadCodeBlock>
=======================================================

Problem in using this hacks in one grid. if enable grid's "onCommand" eventhandler - attachments works correct, but exporting freezes grid infinitly. if disable "onCommand" handler - export works correct, but attachments can't download from ajax-enabled grid.

0
yerlan
Top achievements
Rank 1
answered on 27 Jul 2010, 01:13 PM
Anyone have workaround?
0
Daniel
Telerik team
answered on 29 Jul 2010, 09:08 PM
Hello Yerlan,

I recommend that you try to use only the first approach. You just need to add the ID of the button that triggers the DownloadAttachment command.

Sample code:
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:Button ID="DownloadButton1" runat="server"
             Text="Download"
             CommandName="DownloadAttachment" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

function onRequestStart(sender, args) {
    if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
        args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
        args.get_eventTarget().indexOf("ExportToPdfButton") >= 0 ||
        args.get_eventTarget().indexOf("ExportToCsvButton") >= 0 ||
        args.get_eventTarget().indexOf("DownloadButton1") >= 0) {
        args.set_enableAjax(false);
    }
}

Regards,
Daniel
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
yerlan
Top achievements
Rank 1
answered on 29 Jul 2010, 09:46 PM

Hello, Daniel.

I'm removed GridAttchmentColumn and added GridTemplateColumn as in your code. Also I'm added ItemCommand event handler to RadGrid, but when i'm press to download button - event handler not executes (not only "DownloadAttachment" command, for all commands). What i'm doing wrong?

01.<telerik:RadGrid ID="MyGrid" runat="server"
02.    OnItemCommand="OnItemCommand">
03.    <ClientSettings AllowColumnsReorder="true" ColumnsReorderMethod="Reorder">            
04.        <Resizing AllowColumnResize="True" ResizeGridOnColumnResize="true"/>
05.    </ClientSettings>       
06.    ...         
07.        <telerik:GridTemplateColumn UniqueName="MY_BLOB_COLUMN">
08.            <ItemTemplate>
09.            <asp:LinkButton ID="DownloadAttachmentButton" runat="server"
10.                Text='<%# DataBinder.Eval(Container, "DataItem.MY_BLOB_COLUMN")%>' 
11.                        CommandName="DownloadAttachment"/>
12.            </ItemTemplate>
13.            <EditItemTemplate>
14.            <telerik:RadAsyncUpload runat="server" ID="AsuExamConclusionFile" 
15.                           MaxFileSize="104857600"                  HttpHandlerUrl="~/CustomAsyncUploadHandler.ashx" MaxFileInputsCount="1" 
16.                        OnClientDeleting="OnClientDeleting" OnClientFileUploaded="OnClientFileUploaded"/>
17.                </EditItemTemplate>
18.        </telerik:GridTemplateColumn>
19.    ...
20.</telerik:RadGrid>

1.protected void OnItemCommand(object source, GridCommandEventArgs e)
2.{
3.    if (e.CommandName == RadGrid.DownloadAttachmentCommandName)
4.    {
5.                  
6.    }
7.}

0
Daniel
Telerik team
answered on 04 Aug 2010, 10:09 PM
Hello Yerlan,

This approach works fine on my end. Please download the attached project (stripped for the sake of simplicity) and let me know if I'm missing something.

Regards,
Daniel
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
Jeff
Top achievements
Rank 1
answered on 25 Aug 2010, 08:45 PM
I tried the sample code, but there is no <ClientEvents /> element available on the RadAjaxManagerProxy.....
0
Daniel
Telerik team
answered on 31 Aug 2010, 09:53 AM
Hello Jeff,

You have to attach the event handler to the RadAjaxManager in the MasterPage. Of course, this means that the JS code should also be placed there.

Regards,
Daniel
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
Rajesh
Top achievements
Rank 2
answered on 20 Sep 2010, 04:29 PM
Hello Daniel...

This Works Fine..

Thanks
0
Tony
Top achievements
Rank 1
answered on 02 Mar 2011, 12:21 AM
I have a situation that has the same issues as Yerlan found, but different circumstances. I am using a grid with the GridEditCommandColumn column and another column with a delete button. My grid is ajaxified via RadAjaxManager. I want to either hide the delete button column on edit, or trap deletions when editing (and cancel them) because you can be editing an item and delete another item, which can cause side-effects (if the item you delete is above the one you are editing, when the delete completes, you are not editing the item you were before the delete). So, I need to have a client-side handler for OnCommand. However, if I have such a handler, exporting no longer works. I cannot figure out why this is, but exporting is definitely broken if you define an OnCommand handler client-side. I have tried returning true, false and not returning anything from the OnCommand handler and it doesn't fix the export problem.

So, the basic question is, how do I get a client-side OnCommand handler to not break the exporting capabilities? I am using the built-in buttons, and the infrastructure is correct in that, without the OnCommand handler, exporting works.
0
Daniel
Telerik team
answered on 07 Mar 2011, 01:39 PM
Hello Tony,

I strongly recommend that you avoid attaching the client-side OnCommand handler when binding RadGrid on the server since this will cause problems in some scenarios.
This event is supported with client-side binding only.

Best regards,
Daniel
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Tony
Top achievements
Rank 1
answered on 09 Mar 2011, 10:32 PM
Is there another method, then, for trapping the delete button click when a user is editing an item? Frankly, it seems like the grid control should be handling this - I would think that editing would need to be completed before you are allowed to do anything else, as though the editing operation is "modal" for the control. Is there some way I can handle this? I have thought of trapping it on the server side, but I am not going to know, on the server, if the user is in edit mode on the client, am I?
0
Daniel
Telerik team
answered on 15 Mar 2011, 12:48 PM
Hello Tony,

Generally speaking you have to use server-side approach in this case.
The easiest way would be to handle the ItemCommand event and cancel the Delete command:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.DeleteCommandName && RadGrid1.EditIndexes.Count > 0)
    {
        e.Canceled = true;
        RadAjaxPanel1.Alert("Delete operation disabled when edit mode is active!");
    }
}

Of course it is also possible to hide the delete column if you prefer to do so.

I hope this helps.

Regards,
Daniel
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
yerlan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
yerlan
Top achievements
Rank 1
Jeff
Top achievements
Rank 1
Rajesh
Top achievements
Rank 2
Tony
Top achievements
Rank 1
Share this question
or