2009-07-13 24 views
0
<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返回的對象沒有問題。Flex中列的數據

回答

1

你試過調試嗎?我建議在設置var appSes之後立即運行帶有斷點的調試,並檢查該變量以確保ArrayCollection正在使用e服務結果數據正確創建。

如果正確創建了ArrayCollection,接下來確保dataField名稱與ArrayCollection中的數據正確匹配 - 這些區分大小寫。嘗試從DataGrid中刪除所有列。如果你的ArrayCollection是有效的,則DataGrid會自動在ArrayCollection中的列標題創建dataField對名稱的列:

ArrayCollection: 
    {firstName: "Joe", userID: 1, userlevel: 3, email: "[email protected]"}, 
    {firstName: "Mary", userID: 2, userlevel: 4, email: "[email protected]"}, 
    {firstName: "Bob", userID: 3, userlevel: 2, email: "[email protected]"} 

Will display as the following if you do not specify columns: 

firstName   userId  userLevel email 
------------------- ------------- ------------ ---------------------------- 
Joe     1    3   [email protected] 
Mary    2    4   [email protected] 
Bob     3    2   [email protected] 

希望幫助!

+0

沒問題!樂意效勞! – 2009-07-13 19:47:08

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. 

讓我知道是否有幫助。