4 Replies Latest reply on Dec 11, 2007 2:10 PM by <cf_pt>

    How to check if a DataGrid is Loaded

    <cf_pt> Level 1
      All - I'm new to flex and struggling - getting past simple examples is proving a challenge - but not one that isn't worth taking. I'm trying to display a "loading" message for my users when as I load up many rows into a datagrid. As this may take as much as 10 seconds, it's not enough to simply leave the grid empty.

      I'm having a hard time testing to see if the data grid is loaded - I was thinking of some sort of event listener to check and see if the data grid rows value was GT 1 or something, but I feel like I'm taking the long way around - Can anyone help??

      Thanks!
      PT
        • 1. How to check if a DataGrid is Loaded
          m_hartnett Level 3
          How are you loading the data?
          Are you using a datasource to an xml file?

          I think you can use the valueCommit event to listen for finish loading of the data.

          I am not entirely sure on this ... maybe someone can confirm this.


          • 2. Re: How to check if a DataGrid is Loaded
            <cf_pt> Level 1
            I'm doing the basic XML load via the <mx:HTTPService id="feedRequest"... example in all the beginner books. My dataGrid then has the dataProvider="{feedRequest.lastResult.rss.channel.item}" bit of code to load it up. There's also the creationComplete="feedRequest.send();" bit in the application tag-
            Pt
            • 3. How to check if a DataGrid is Loaded
              m_hartnett Level 3
              You can define another method called creationCompleteHandler();
              This would get called in the creationComplete event instead of feedRequest.send();

              In this new method you can display a message that the data is loading and then call the feedRequest.send();
              private function creationCompleteHandler() : void {
              displayMessageSomehow;
              feedRequest.send();
              }

              The HttpService has an onResult handler for it.
              In the handler you can hide the message.
              Also make sure that the HttpService object has the showBusyCursor set to true.
              This will give the user indication that the data is loading as well.
              • 4. Re: How to check if a DataGrid is Loaded
                <cf_pt> Level 1
                Yes! Just what I was looking for - the HTTPService onResult handler is the ticket! Got it running now! Thanks!!!!
                Pt