1 Reply Latest reply on Dec 22, 2011 5:41 AM by jovi.verheyen

    selectedIndex doesn't 'stick' after function executes

    jovi.verheyen

      Hi all,
      I've got this problem in a windowed application i'm trying to code for school.
      The situation is as follows:
      1 datagrid with a sqlite local database behind it. In this datagrid I only show 1 column of the data namely the cocktail's name.

       

      Whenever the user selects a cocktail in the list, its properties are displayed in the 2 textareas on the right of the screen.
      I call the function in the datagrid with this code

      Code:

       

      change="fillIng(event);"
      the code used in my function to populate the textArea is as follows:

       

      Code:

       

      private var selectIng:SQLStatement = new SQLStatement; private function fillIng(event:ListEvent):void { selectIng.sqlConnection = sqlc; selectIng.text = "SELECT cocktail_ingredients FROM cocktails_table WHERE id="+dp[dg.selectedIndex].id; selectIng.addEventListener(SQLEvent.RESULT, ingResult); selectIng.execute(); }  // Functie die de opgehaalde ingredienten van de vorige functie invult in het textArea ingredients_text private function ingResult(event:SQLEvent):void { var resultIng:SQLResult = selectIng.getResult(); var rowIng:Object = resultIng.data[0]; ingredients_text.text = rowIng.cocktail_ingredients; refresh(); }
      Now, the problem is, after I choose a cocktail from the list, the datagrid seems to forget what item is selected. I do need the selectedIndex in other functions (like the buttons edit and delete.)

      Schermafbeelding 2011-12-22 om 10.57.16.png

      I hope somebody will be able to help me out!
      Thanks in advance