在我的示例应用程序(Java Flex)Java类方法中,类似于..
public class Sample
{
public ArrayList method1()
{
ArrayList al =new ArrayList();
al.add("one");
al.add("TWO");
}
且在弹性方面连接燃烧的连接...所有这些都完美完成,我的MXML file code
是
public var userService:Sample = new Sample();
protected function init_Call(event:FlexEvent):void
{
var rpcSearchResult:AsyncToken = userService.method1();
rpcSearchResult.addResponder(new mx.rpc.Responder(success, failure));
}
[Bindable]public var ac:ArrayCollection = new ArrayCollection();
public function success(event:ResultEvent):void
{
ac=event.result as ArrayCollection;
Alert.show("Result : "+ac.getItemAt(0,0));
}
public function failure(event:FaultEvent):void
{
Alert.show("This is Fault Event");
}
......
<s:DataGrid id="dataGrid" left="12" right="12" top="49" bottom="54" horizontalCenter="0"
requestedRowCount="4" verticalCenter="-3" dataProvider="{ac}">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="one" headerText="FirstValue"></s:GridColumn>
<s:GridColumn dataField="two" headerText="SecondValue"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
,但我在datagrid上没有任何值,但是结果event函数警报显示"一个","两个"值正确。
我怀疑问题可能在您分配给 datagrid 的变量中。尝试设置" ac "为 [可绑定] 或替换您的功能成功以下:
public function success(event:ResultEvent):void
{
datagrid.dataProvider = event.result;
}
我希望它会有所帮助。