Download within Grid Command and Command Handler of file

  1. #1

    Download within Grid Command and Command Handler of file

    Hey guys,

    a few weeks ago, we bought some licences in our company for and now there comes up my first question :-)

    I already looked up other threads here to find the answer but nothing helped for me.
    the problem is the following:

    i have a grid Panel that lists me the files of a folder with it's name, size, description etc. no problem. Now for each "file-row", i have a download "Button", which should download the file by clicking it:

    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <form runat="server">
            Title="Folder content"
                <ext:Store runat="server">
                                <ext:RecordField Name="fileIcon" Type="String" />
                                <ext:RecordField Name="fileName" Type="String" />
                                <ext:RecordField Name="fileFullname" Type="String" />
                                <ext:RecordField Name="fileSize" Type="Int" />
                                <ext:RecordField Name="uploadDate" Type="Date" />
                                <ext:RecordField Name="description" Type="String" />
            <ColumnModel runat="server">
                    <ext:RowNumbererColumn />
                    <ext:Column DataIndex="fileIcon" Header="Icon" Width="260px"/>
                    <ext:Column DataIndex="fileName" Header="Name" Width="260px"/>
                    <ext:Column DataIndex="fileFullname" Header="Fullname" Width="260px" Hidden="true"/>
                    <ext:NumberColumn DataIndex="fileSize" Header="Size" Width="260px"/>
                    <ext:DateColumn DataIndex="uploadDate" Header="UploadDate" Width="260px"/>
                    <ext:Column DataIndex="description" Header="Beschreibung" Width="260px"/>
                    <ext:CommandColumn Header="Download" Width="60">
                            <ext:GridCommand Icon="DiskDownload" CommandName="download">
                                <ToolTip Text="Download" />
                <ext:RowSelectionModel ID="RowModel" runat="server" SingleSelect="true" />
                <Command Handler=";"/>
    the DirectMethod "downloadFile" looks like that, i just tested it now for an Excel document, i know i will need a switch case for defining the Mime type of the document:

            public void downloadFile(string filepath)
                    // filepath is now: C:/user/testuser/test.xls
                    string type = "application/msexcel";
                    String FilePath = filepath.Replace("/", "\\");
                    String FileName = FilePath.Substring(FilePath.LastIndexOf("\\") + 1);
                    // FilePath is now: C:\users\testuser\test.xls"
                    // FileName is now: test.xls
                    Response.Buffer = true;
                    Response.ContentType = type;
                    Response.AddHeader("Content-Type", type);
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
                catch (Exception ex)
                    X.Msg.Alert("error", "data not found").Show();
    if i try that code, i get the error "BADRESPONSE: illegal character" .. i read that i need an IsUpload="true"..somewhere.. but could not find the right place for it by using a command handler for a Grid command.

    I hope you can help me out here :-)

    Best regards,
  2. #2
    i'm trying to use now a normal ext:button instead of a GridCommand.
    Will tell you what i found out after.

    Edit: In V1 i cannot add :
    <ext:ComponentColumn runat="server" Flex="1">
                            <ext:Container runat="server" Height="22">
                                    <ext:Button runat="server" ItemID="Trigger" Text="Download">
                                            <Click Handler=";"/>
    Last edited by novacp; Aug 08, 2013 at 8:31 AM.
  3. #3
    fixed with direct event instead of a listener.

Similar Threads

  1. Replies: 13
    Last Post: Jun 05, 2013, 8:51 PM
  2. [CLOSED] ImageCommandColumn command handler
    By jchau in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Jan 11, 2013, 6:44 PM
  3. Replies: 4
    Last Post: Dec 27, 2011, 5:11 PM
  4. how to make Command Handler ViewStateEnabled
    By harshad.jadhav in forum 1.x Help
    Replies: 3
    Last Post: Dec 02, 2010, 7:47 AM
  5. [CLOSED] Download file in grid command column click
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 31, 2010, 12:08 PM

Tags for this Thread

Posting Permissions