flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trevor Holman" <trev...@mchsi.com>
Subject AIR
Date Sat, 26 Aug 2017 16:23:31 GMT
I'm trying to set the contents of a DataGrid based on the selection of a
drop down. I created a DatabaseManager class to handle all the sqlite
communications however I can't seem to get the variable holding the
ArrayCollection to set before it's called in my main file. So that makes
each selection  of the dropdown populate the DataGrid with the previous
dropdown selection content. I'm using Flash Builder.

 

                                                This code sends the
selection from the dropdown using an event on the dropdown.

                  

                  protected function
categorySelected(event:IndexChangeEvent):void {

                        var catName:String = listName.selectedItem;

                        getItemsByCategory.getList(catName);

                        

                        mainListArea.dataProvider =
getItemsByCategory.myResults;

 

                  }

 

                                These functions are in the DatabaseManager
class. I have a private variable at top and I use a getter function with it.


 

private var _myResults:ArrayCollection;

 

            

            //get list based on category selection

            public function getList(name:String):void {

                  selectStmt.sqlConnection = conn;

                  var query:String = "SELECT * FROM " + name + "";

                  selectStmt.text = query;

                  try {

                        selectStmt.addEventListener(SQLEvent.RESULT,
resultHandler);

                        //selectStmt.addEventListener(SQLErrorEvent.ERROR,
errorHandler);

                        selectStmt.execute();

                  } catch(error:SQLError) {

                        trace("Error Message: " + error.message);

                  }

            }

            

            //handle result of getList function

            public function resultHandler(event:SQLEvent):void {

                  var result:SQLResult = selectStmt.getResult();

                  

                  var temp:Array = result.data is Array ? result.data :
[{rows:result.rowsAffected}];

                  _myResults = new ArrayCollection(temp);

                                    

            }

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message