4 Replies Latest reply on Apr 16, 2008 8:17 AM by cialeen

    Progress Bar

      Hello everyone,

      Hope this is a simple question!

      I want to export my datagrid data to excel, so I just loop through every cell to generate HTML string. But because the data amount is too large, it will take tens of seconds to process it. So I want to give a client a progress bar to indicate how much time left.

      But the problem is the progress bar seems only update after all the process finished, that is the application is too busy and looks like stopped during the runtime. Can I make the progress bar keep updating and the process "export to excel" run in the backgroud. Or can I have two threads to run two different processes?

      Thank you very much.

        • 1. Re: Progress Bar
          Vackar Level 2
          Can I ask, how do you actually do the export. Do you generate an EXCEL file and save it to the server, and then link to the file on the server, or do you pass it directly to the client without writing to the server?
          • 2. Re: Progress Bar
            cialeen Level 1

            I used the navigateToURL(request, "_blank") to open a page on the server after I generate all data to HTML string.

            I tried to use ExternalInterface API to access Javascript in the wrapper page, but it only works for Firefox not for IE. It kept saying that "trend" is undefined. (which trend is the of in the embed object.) So I gave up but actually this method is my preferred solution.

            Any suggestions for the progress bar???

            Thank you very much.

            • 3. Re: Progress Bar
              ericbelair Level 1
              I created my own Progress Bar component, setting properties that will always keep the bar moving, and then show/hide the component using event listeners and handlers (see attached code).
              • 4. Re: Progress Bar
                cialeen Level 1
                Thank you very much for your reply, Eric.

                I tried your code but it didn't work for me.

                My code is
                private function openPage( pageFormat:String ):void
                this.dispatchEvent( new Event( "dataRetrievalStart" ) );

                if ( dataHtml == "" )
                dataHtml = convertDataToHTMLDisplay();

                this.dispatchEvent( new Event( "dataRetrievalEnd" ) );

                The method "convertDataToHTMLDisplay" will do the actual converting job. When run method "openPage", first dispatch an event to make progress bar visible, and then go to the convertion, remove progress bar. But to the client's point of view is the progress par never show up and application is stopped for a while (actually busy for generating HTML).

                If I remove the latst line :
                this.dispatchEvent( new Event( "dataRetrievalEnd" ) );
                then it looks like the progress bar will show up after the generation finished. That's no use for me.

                The thing I want to do is while the application is doing the HTML generation, the progress bar can show the status at the same time.

                Please help!