I have an sqlite db in an application and am stuck on how to pass the data that is retrieved from the db into multiple textboxes. I can get the first selection passed into the components just fine, but my problem comes in when I try to pass a second data selection into a different textbox while keeping the data from the previous selection the same in the first textbox.
Basically, the user selects a recipe and that recipe is passed into textbox 1. Then another recipe is selected and that recipe is passed into textbox 2. *The recipes are selected from a different view, if that adds anything to the problem. After being selected, the view is returned to where the textboxes are.
I'm not looking for someone to code this for me, but rather on how I would do it. I should be able to do that. =)
Thank you so much for any and all advice.
My Text Components
<s:Group id="group1" x="412" y="156" width="200" height="206" contentBackgroundAlpha="1.0" >
<s:TextInput id="tText1" x="22" y="30" width="157" height="25" fontSize="12"
text="{data.kTitle}"/>
<s:TextArea id="iText1" x="11" y="63" width="178" height="133" editable="false" fontSize="12"
text="{data.kIngredients}"/>
<s:Label id="timer1" x="174" y="8" click="timer1_clickHandler(event)" fontSize="13"
text="00"/>
<s:Label x="169" y="7" fontSize="13" text=":"/>
</s:Group>
<s:Group id="group2" x="754" y="37" width="200" height="206" visible="false">
<s:TextInput id="tText2" x="22" y="28" width="157" height="26" fontSize="12" text="{data.kIngredients}"/>
<s:TextArea id="iText2" x="10" y="63" width="178" height="133" editable="false" fontSize="12" text="{data.kTitle}"/>
<s:Label id="timer2" x="176" y="7" click="timer2_clickHandler(event)" fontSize="13" text="00"/>
<s:Label x="173" y="7" fontSize="13" text=":"/>
</s:Group>
Upon clicking "make the recipe" button - pushes recipe data back to main view
protected function viewRecipeButton_clickHandler(event:MouseEvent):void // make recipe button pushed
{
if(recipeList.selectedItem != null)
navigator.push开发者_如何学PythonView(views.Timer_view, recipeList.selectedItem);
}
How I'm getting the SQlite data
protected function getAllRecipes():void // get all the recipes from the DB
{
var stmt:SQLStatement = new SQLStatement();
var conn:SQLConnection = new SQLConnection();
stmt.sqlConnection = conn;
conn.open(File.applicationStorageDirectory.resolvePath("Recipes.db"));
stmt.text = "SELECT * FROM kItems WHERE kTitle IS NOT NULL";
stmt.execute();
recipeList.dataProvider = new ArrayCollection(stmt.getResult().data);
conn.close();
}
What you want are item renderers, possibly in a List or DataGroup. What you need to do is send your data over in an array, pass that array to a List and have the list display the information you need. In your cause it would be something like this:
<s:List dataProvider="{recipes}">
<s:itemRenderer>
<fx:Component>
<fx:ItemRenderer>
<s:TextInput text="{data.kTitle}"/>
<s:TextArea text="{data.kIngredients}"/>
</fx:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
精彩评论