2009-07-11 6 views
0

PHP에서 배열로 반환 유형을 가져옵니다. 내 DataGrid에 채울 때, 값은 오지 않을거야 ... 나는 왜 이런 일이 일어나고 있는지 해명하지 않습니다.Flex Datagrid에서 배열 채우기

var appSes:Array = event.result as Array 
dg.dataProvider = appSes; 

PHP에서 값을 가져 오는 중 내가해야 할 일이 있습니다.

<local:CheckBoxDataGrid id="dg" 
        allowMultipleSelection="true" x="118" y="142" width="507"> 
     <local:columns> 
      <mx:DataGridColumn dataField="firstName" headerText=" " width="20" sortable="false" itemRenderer="CheckBoxRenderer" > 
      </mx:DataGridColumn> 
      <mx:DataGridColumn dataField="firstName" headerText="First Name" /> 
      <mx:DataGridColumn dataField="lastName" headerText="Last Name" /> 
     </local:columns> 
    </local:CheckBoxDataGrid> 

답변

0

배열이 아닌 ArrayCollection을 사용하십시오. 일반적으로 ArrayCollection은 List, Grids 등의 dataProviders에 바인딩 할 때 항상 속성 변경을 인식하므로 객체가 추가되거나 제거되거나 이 변경 될 때마다 List에 알립니다.. 배열은이 동작을 제공하지 않습니다.

내가 모델이 당신처럼 명시 적으로 설정하는 것이 아니라 객체에 내 의견을 결합하는 경향이

var appSes:ArrayCollection = new ArrayCollection(event.result); 
dg.dataProvider = appSes; 

에 VAR를 변경

. ArrayCollection의 새 인스턴스를 만들면 (예 : 서버에서 데이터를 새로 고침 할 때) 내 부분에 대한 추가 노력없이 문제가 올바르게 업데이트된다는 이점이 있습니다.

따라서

, 나는 할 것이다 :

<local:CheckBoxDataGrid id="dg" dataProvider="{appSes}" .... 
관련 문제