2010-02-21 2 views
1

나는 편집 가능한 DataGrid에 바인딩 된 ArrayCollection을 가지고 있으며, 다른 구성 요소는 ArrayCollection의 변경 사항 (DataGrid의 변경 결과)을 알아야만 자신을 업데이트 할 수 있으므로 ArrayCollection의 COLLECTION_CHANGE 이벤트도 수신 대기해야합니다.Flex : 데이터 그리드에 바인딩 된 ArrayCollection을 변경하려면 어떻게해야합니까?

문제는 편집중인 행이 포커스를 잃을 때 DataGrid가 ArrayCollection 만 업데이트한다는 것입니다. 사용자가 행의 열을 편집 할 수 있고 오랜 시간 동안 표의 다른 곳을 클릭하지 않아서 행이 흐려지기 때문에 내 앱에 좋지 않습니다. 따라서 변경 사항은 다른 부분으로 전파되지 않습니다. 응용 프로그램.

행이 포커스를 잃을 때마다 대신 텍스트 입력에 keyup 이벤트가 발생할 때마다 데이터 그리드에서 변경 사항을 ArrayCollection에 알릴 수 있습니까?

건배,

크리스

답변

1

나는 값을 편집하는 대신있는 ArrayCollection에하는 데 사용되는 구성 요소에 처리기를 추가합니다. 예 :

<mx:DataGridColumn dataField="name" headerText="Name" itemEditor="{nameEditor}" editorDataField="selectedItem" /> 
다음이 값을 수정하기 위해 사용된다

:

<mx:Component id="nameEditor"> 
    <mx:ComboBox dataProvider="{outerDocument.names}" change="outerDocument.setNameField(event)" close="outerDocument.setNameField(event)" /> 
</mx:Component> 

하고이 변화 (닫는) 이벤트 핸들러이다

public function setDestinationField(event:*):void { 
    var destination:String = (event.target as ComboBox).selectedLabel; 
    if (destination === '') { 
     delete _gridData[_currentlyEditedRowIndex].destination; 
    } else { 
     _gridData[_currentlyEditedRowIndex].destination = destination; 
    } 
} 

_currentlyEditedRowIndex 의해 설정된 그리드에 추가 :

0

감사합니다. 가브리엘은 나를 올바른 길로 인도했습니다. 나는 다른 사람들이 미래에 같은 일을 할 필요가있을 때를 대비해 나의 최종 해결책을 게시 할 것이다. 텍스트가있는 ArrayCollection은 데이터 공급자로 사용되는 입력에 변경 이제 때마다

<mx:DataGridColumn headerText="Title" width="300" dataField="title"> 
    <mx:itemEditor> 
     <mx:Component> 
     <mx:TextInput change="data.title = text" /> 
     </mx:Component> 
    </mx:itemEditor> 
    </mx:DataGridColumn> 

는 너무 다른 구성 요소는 COLLECTION_CHANGE 이벤트를 수신, 업데이트됩니다.

관련 문제