我有一個數組填充輸入從SQLite
數據庫。當我使用這個數組作爲s:list的數據提供者時,它將顯示我指定的數組中的所有對象。
我想訪問數組中的一些對象,並試圖使用getItemAt()
。此刻,我可以返回數組中的第一個對象,但更改索引(例如getItemAt(1)
),它不返回任何內容。Flex:訪問使用'getItemAt()'SQLite條目'
最終,我的目標是在應用程序的其他位置輸入數據並將其插入到SQLite
數據庫中,以填充FX:Model。然後,該模型將作爲餅圖的數據提供者。我可以將數據庫的第一個條目傳遞給模型/餅圖,但無法訪問其他數據庫。
一些相關的代碼段如下。疑難解答提示將不勝感激。
[Bindable]
private var GHGsource:ArrayCollection;
然後:
GHGsource = new ArrayCollection();
}
for each (var o:Object in event.data)
{
GHGsource.addItem(o);
}
FullList.dataProvider = GHGsource;
}
}
模型設置:
<fx:Declarations>
<fx:Model id="GHG" >
<data>
<row>
<input>Enteric methane</input>
<Value> {GHGsource.getItemAt(0).answer} </Value>
列表設置:
<s:List id="FullList">
<s:itemRenderer>
<fx:Component>
<s:IconItemRenderer labelFunction="returnQuestion" messageFunction="returnAnswer">
<fx:Script>
<![CDATA[
private function returnQuestion(item:Object):String
{
return "Question: " + item.question;
}
private function returnAnswer(item:Object):String
{
var response:String = "";
if (!item.answer || item.answer == "")
{
response = "(no response)";
} else {
response = item.answer;
}
return response;
}
]]>
</fx:Script>
</s:IconItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
此應用程序是基於載於Daniel Koestler's survey ape application的數據庫結構。
也許深入瞭解s:List組件如何訪問數組中的對象在這裏會有所幫助?
其他詳細信息:
在調試模式下運行它好像該對象不正確綁定到一個ArrayCollection。 警告:無法綁定到類'對象'上的屬性'xxx'(類不是IEventDispatcher)
我試圖按照以下鏈接指南,但尚未成功。
link1 link2