<local:CheckBoxDataGrid id="dg"
allowMultipleSelection="true" x="118" y="151" width="557">
<local:columns>
<mx:DataGridColumn dataField="firstName" headerText="Select" width="50" sortable="false" itemRenderer="CheckBoxRenderer" >
</mx:DataGridColumn>
<mx:DataGridColumn id="userID" headerText="User ID" />
<mx:DataGridColumn dataField="userlevel" editable="true" headerText="Role" />
<mx:DataGridColumn id="email" headerText="Email" />
</local:columns>
</local:CheckBoxDataGrid>
private function getUs(data:Object):void{
var appSes:ArrayCollection = new ArrayCollection(data.result);
dg.dataProvider = appSes;
}
我将值作为ArrayCollection获取,但是当我将它绑定到我的Datagrid时,我没有得到任何值....虽然从PHP返回的对象很好。
答案 0 :(得分:1)
你试过调试吗?我建议在设置var appSes后立即运行带有断点的调试,并检查该变量以确保ArrayCollection正在使用e Service结果数据正确创建。
如果正确创建了ArrayCollection,请确保dataField
名称与ArrayCollection中的数据正确匹配 - 这些名称区分大小写。尝试从DataGrid中删除所有列。如果您的ArrayCollection有效,DataGrid将自动创建ArrayCollection中具有dataField名称的列作为列标题:
ArrayCollection:
{firstName: "Joe", userID: 1, userlevel: 3, email: "joe@foo.com"},
{firstName: "Mary", userID: 2, userlevel: 4, email: "mary@foo.com"},
{firstName: "Bob", userID: 3, userlevel: 2, email: "bob@foo.com"}
Will display as the following if you do not specify columns:
firstName userId userLevel email
------------------- ------------- ------------ ----------------------------
Joe 1 3 joe@foo.com
Mary 2 4 mary@foo.com
Bob 3 2 bob@foo.com
希望有所帮助!
答案 1 :(得分:0)
我的第一个建议是测试这个,而不用通过PHP加载东西。将数据复制到本地ArrayCollection并基于此进行分配。
您也可能想要初始化dataprovider属性(这有时会有所帮助,尽管事实上它不是假设的):
<local:CheckBoxDataGrid id="dg" dataProvider="{ myArrayCollection }"
...
[Bindable]
private var myArrayCollection:ArrayCollection
...
private function getUs(data:Object):void
{
myArrayCollection = new ArrayCollection(data.result);
trace( myArrayCollection ); // Just a sanity check.
如果有帮助,请告诉我。