在flex builder 4.6中,我尝试绑定来自sql查询的数据,在<s:List>
中显示了一个项呈示器<s:Textarea>
<s:List id="listapagar" x="304" y="276" width="330" height="42" borderVisible="false"
color="#FF0000" dataProvider="{dataProvider}" enabled="false" fontSize="22"
fontStyle="italic" fontWeight="bold" labelField="nome" textAlign="center"
textDecoration="underline">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:TextArea id="apagar" width="330" height="42" text="R$ {data.valorapagar}" />
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
在这里,我的sql显示在<s:list>
:
protected function buttonX():void
{
var sqlConnection:SQLConnection = new SQLConnection();
sqlConnection.open(File.applicationDirectory.resolvePath("testeDb.sqlite"));
var stmt:SQLStatement = new SQLStatement();
stmt.sqlConnection = sqlConnection;
stmt.text = "SELECT * FROM comandatual order by numerodatransacao desc limit 1 ";
stmt.execute();
dataProvider = new ArrayCollection(stmt.getResult().data);
}
之后,我试图将结果显示在s:TextArea id =“apagar”并与另一个文本区域绑定,以执行简单的减去calc,如下所示:
<fx:Binding source="apagar.text" destination="restroco.text"/>
<fx:Model id="Calculos" >
<Calculos>
<!-- Perform a calculation. -->
<a>{(Number(restroco.text)) - 3}</a>
</Calculos>
</fx:Model>
但此时,flex会返回一个不能让我前进的错误:
1120:访问未定义的属性apagar。弹性问题
所以,我被困了,如果有人想看到我的完整代码,他们就在这里:
答案 0 :(得分:0)
@RIAStar解释说,您的fx:Model
无法访问apagar
。除了建议的解决方案,您还可以使用IndexChangeEvent
:
<fx:Script>
<![CDATA[
import spark.events.IndexChangeEvent;
private var apagarNum:Number = NaN;
protected function selectionChangedHandler(event:IndexChangeEvent):void
{
apagarNum = Number(listapagar.selectedItem.valorapagar);
}
]]>
</fx:Script>
<fx:Model id="Calculos" >
<Calculos>
<!-- Perform a calculation. -->
<c>{(Number(restroco.text)) - 3}</c>
<!-- calcular com valor a pagar -->
<d>{apagarNum - 3}</d>
</Calculos>
</fx:Model>
<s:List id="listapagar" change="selectionChangedHandler(event)" ...>