2011-03-22 10 views
0

에 발신자 개체 ID를 전달하여 여러 DataGrids를 액세스하는 내가 일하고 있어요 플렉스/PHP 응용 프로그램을FLEX는 : 동적 기능

를 해결했다.

데이터 소스에 대해 하나의 ArrayCollection을 보유하고 있지만 이름이 dg1에서 dg8 인 8 개의 DataGrid가 있습니다. 논리적 인 표현 (대학 4 년, 1 년에 2 학기)을 위해 8 개의 DataGrid를 사용합니다. 클릭하면 "X"("이 레코드 삭제"용) 열에 함수로 이동합니다.

데이터 격자 ID (예 : "dg1")와 데이터 공급자 {syllabus.freshFall}를 함수에 전달하고 싶습니다. 나는이를 만들고 싶어

course_id=dg1.selectedItem.course_ID; 
syllabus.freshFall.removeItemAt(dg1.selectedIndex); 

: 나는이 작업을 수행하는 방법을 찾을 수 내 어려운 시도했습니다,하지만 하나의 DataGrids를 예를 발견했다 (이 꽤 쉽게 볼)과 같은 하나의 고정 데이터 그리드를 참조 이 같은 :

course_id=**whateverDataGrid**.selectedItem.course_ID; 
**whateverDataProvider**.removeItemAt(**whateverDataGrid**.selectedIndex); 

지금 내 HTTPService를 내 C_ID 변수를 전달하는 도움이 필요합니다.

여러분의 도움에 감사드립니다!

답변

0

PARTIAL 답변 : 도움

<mx:LinkButton label="X" click="outerDocument.itemClickEvent('1',event)"/> 


public function itemClickEvent(id:String, event:MouseEvent):void { 
     var mydp:Object; 
     switch(int(id)) 
     { 
      case 1: 
       mydp=syllubus.freshFall; 
       break; 
           . 
           . 
          case 8: 
       mydp=syllubus.seniorSpring; 

      default: 
       trace("Out of range"); 
       break; 
     } 
     id = "dg" + id; 
     c_id=this[id].selectedItem.course_ID; 
     mydp.removeItemAt(this[id].selectedIndex); //superficial datagrid delete 

Adobe LiveDocs for Flex 3에서 나는 여전히 완료된 것으로, 변수의 데이터 프로 바이더 더하고 싶습니다. 몇 가지 다른 접근법을 시도하고 사례 진술은 내가 원한 것에 가장 가깝고 은 현재을 처리했습니다.

내 c_id 변수를 내 함수에서 내 HTTPService로 전달했습니다. 정확히 똑바로 내가 기대했던 것만 큼 ...

오브젝트 유형에 변수를 빌드하십시오. 전달할 변수 이름의 오브젝트에 요소를 추가하십시오. 변수에 값을 추가하십시오 . 이 것처럼 보이는

전달이 다른 사람 도움

function blah (var:int, ...rest):void { 

code... 

code... 

c_id= *whatever*; 
params["cid"] = c_id; 
update.send(params); (where "update" is the HttpService id) 
} 

. 
. 
. 
. 

<mx:HTTPService 
    id="update"  
    url="http://localhost/myFile.php" 
    method="POST" 
    etc...> 
<mx:request> 
    <xmlstring>{XMLString}</xmlstring> (this xml string is generated elsewhere) 
    <cid>c_id</cid> 
</mx:request> 
</mx:HTTPService> 

희망을. 이 모든 것을한데 모으는 것은 약간의 고통이었습니다.