Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: [SOLVED] Downloading files without window.open(), or opening a window iframepanel.

  1. #1
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638

    Lightbulb [SOLVED] Downloading files without window.open(), or opening a window iframepanel.

    Is there a way to download a file without window.open or iframepanel within a window? The problem is when I use window.open(), Popup blockers block the download, which is annoying.

    So I was trying to come up with an alternative to have the iframepanel open in a window, however, the user then has to close the window. I introduced a delay to close the window, but if the request has not completed, then the download will not start. Alternatively, I tried doing a Ext.Ajax.request(), but that doesn't work.

    Ultimately, I just want the standard download window to download the file.

    Has anyone encountered this, and what the solution might be?

  2. #2
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638

    Lightbulb Workaround.

    I guess this will have to do... Not the greatest implementation, but it works.

    Code:
        download: function () {
            for (var i = 0; i < this.downloadList.length; i++)
            {
                var cfg = {
                    closable: true,
                    width: 1,
                    height: 1,
                    x: 1,
                    y: 1,
                    shadow: false,
                    defaultSrc: this.downloadList[i].url,
                    listeners: {
                        show: function (o) {
                            o.close();
                        },
                        delay: 60000
                    }
                };
                var win = new Ext.ux.ManagedIFrame.Window(cfg);
                win.show();
                win.hide();
            }
        },

  3. #3
    Sencha User
    Join Date
    Mar 2008
    Posts
    566

    Default

    I picked this up in the forum some time ago. work great.

    Code:
    {
    			text: 'Export As CSV',
    			handler: function(){
    				try {
        				Ext.destroy(Ext.get('downloadIframe'));
    				}
    				catch(e) {}
    				Ext.DomHelper.append(document.body, {
       					tag: 'iframe',
        				id:'downloadIframe',
        				frameBorder: 0,
        				width: 0,
        				height: 0,
        				css: 'display:none;visibility:hidden;height:0px;',
        				src: 'includes/download-csv.asp?tableName=<%=formTitle%>&tableid=<%=tableID%>'
    				});
    				}
    			}

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Use a LinkButton.

    I thought everyone had heard of it!

  5. #5
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638

    Default

    If I use the LinkButton, I would need to invoke it rather than provide a display for it. I have a button that calls the download function of a list of downloads that need to be downloaded.

    Could you provide an example Animal how I might achieve this?

    @moegal: thanks for the code, however I can't use id, because I am downloading a list of url's, and this would essentially, destroy the previous download before it even starts.

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    It's just a link. Click it, and download.

  7. #7
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638

    Default

    @Animal: The LinkButton seems like a more elegant way of requesting a download. What is the function call to click it programatically, or what is the method I need to call - onClick(), click().

    Code:
                var button = new Ext.LinkButton({href: this.kmlLinksList[i].url});
                button.onClick({});
                delete button;

  8. #8
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Force someone to download? Hmm.

    I refer you to http://www.sencha.com/forum/showthre...766#post373766

  9. #9
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638

    Default

    Not exactly. I never want to force anyone to download. The user does have to click a button. Here is the requirement: The Google Earth Panel tracks all of the KML files that have been requested. It stores it in an array. I had to do a workaround to get this list, and sometimes this list changes as the user changes their criteria, and tracks which request is associated with another KML file, so it releases the KML file from memory because it becomes irrelevant.

    What I would ideally like is to just give the resultant KML data within the Google Earth Plug-in sent to the user so as to not tax the system with another round-trip to the server, but it doesn't behave like a download (or at least I am not skilled enough to send it to the user like a download, even though the user already has the data). So the easiest and painless way is to send the urls to the server and download.

    I have a function called download which essential does a window.open() to that list, but because of pop-ups, not all folks are able to download the files. That was the most easiest way of doing this, but now I have to contend with pop-up blockers. Well, an anchor is nice, but what I really want is just to be able to download the file without having to display each and every link. I already have a button that attaches to this function in the map panel.

    I figured that the way I am doing it now works just fine.

    A request shouldn't take more than 60 seconds, so in that time the request should be done, in the meantime the window will just sit in memory-hidden, and destroy itself on the delay.

  10. #10
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    The KML format is not terribly difficult.

    http://code.google.com/apis/kml/docu...n/kml_tut.html

    You can Ajax download it, and extract the information using DomQuery, and then call the GMap API to do whatever.

    (But the above link did show you how to programmatically fire a DOM event)

Page 1 of 2 12 LastLast

Similar Threads

  1. Window hide then close vs window close... Problems re-opening the window.
    By zhegwood in forum Ext 3.x: Help & Discussion
    Replies: 7
    Last Post: 11 Jan 2010, 5:42 PM
  2. browser window crashing in IE while opening FCK editor in window.
    By rockys in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 19 Jun 2009, 2:17 AM
  3. Replies: 5
    Last Post: 23 Jul 2008, 8:49 AM
  4. Replies: 1
    Last Post: 31 Jan 2008, 9:17 AM
  5. Replies: 0
    Last Post: 30 Jan 2008, 10:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •