2009-03-12 5 views
1

ColdFusion의 CFC를 통해 다른 양식 필드와 함께 저장할 수 있어야하는 편집 가능한 DataGrid가 있습니다.플렉스 : CFC를 통해 편집 가능한 DataGrid 저장

기본적으로 목표는 첫 번째 열을 구성하는 RO를 통해 검색되는 위치가 많다는 것입니다. 나머지 열은 인구 통계, 고객 노트, 약속 등의 데이터 유형입니다. 아이디어는 사용자가 각각 그리드의 확인란을 사용하여 데이터 유형을 해당 위치와 공유하게되어 행복 함을 나타냅니다. 위치가 변경되어 시간이 지남에 따라 2 개 또는 4 개 이상이 될 수 있으므로 이러한 방식으로 수행해야합니다.

코드가 지금까지 실행되고 잘 돌아 갔지만 저장 비트가 내 견과를 몰고있다 !! 도와주세요. 사전에

감사 : (정신의 이유로 abreviated) 코드는 다음과 같습니다 :

public function handleconsentResult(event:ResultEvent):void { 
      consentDatagrid.dataProvider = event.result; 
      } 
<mx:RemoteObject id="consentQuery" 
    destination="ColdFusion" 
    source="Build3.consent" 
    showBusyCursor="true"> 
    <mx:method name="getconsent" result="handleconsentResult(event)" fault="fault(event)" /> 

<mx:DataGrid id="consentDatagrid" creationComplete="init()" width="98%" wordWrap="true" textAlign="center"> 
         <mx:columns> 
          <mx:DataGridColumn headerText="Organisation" width="100" textAlign="left" id="Location" dataField="LocationName" wordWrap="true"/> 
          <mx:DataGridColumn headerText="Demographics" width="100" wordWrap="true" textAlign="center" itemRenderer="mx.controls.CheckBox" rendererIsEditor="true" editorDataField="ClientDemographics" /> 
          <mx:DataGridColumn headerText="Appointments" width="100" wordWrap="true" textAlign="center" itemRenderer="mx.controls.CheckBox" rendererIsEditor="true" editorDataField="ClientAppointments"/> 
          <mx:DataGridColumn headerText="Activity" width="70" wordWrap="true" textAlign="center" itemRenderer="mx.controls.CheckBox" rendererIsEditor="true" editorDataField="ClientActivity"/> 
          <mx:DataGridColumn headerText="Notes" width="50" wordWrap="true" textAlign="center" itemRenderer="mx.controls.CheckBox" rendererIsEditor="true" editorDataField="ClientNotes"/> 
         </mx:columns> 
        </mx:DataGrid> 

답변

0

내가 CF에서 플렉스를 알고 있지만 만약 당신이 결정이 없습니다 한꺼번에 저장하거나 일종의 "저장"또는 "전송"작업에 저장 하시겠습니까?

모두를 한꺼번에 저장하려는 경우이 게시물을 Iterating over a ColdFusion Query in Flex에 보내면 도움이 될 수 있습니다.

그렇지 않으면 각 셀의 onChange 이벤트에 Listener을 넣고 실시간으로 씁니다.

1

DataGrid의 전체 내용을 나머지 양식 데이터의 구성원으로 반환하는 것으로 들리는 것처럼 들립니다. 나는 여전히 Flex를 배우고 있지만, AMF를 사용하고 있기 때문에 자동으로 ArrayCollection에서 Query로 변환 될 것이라고 생각합니다.

DataGrid에 dataProvider 특성을 사용하지 않으므로 creationComplete 이벤트에서 호출하는 init 함수의 DataGrid에 ArrayCollection 개체를 바인딩한다고 가정합니다. 이 경우 양식 데이터를 서버에 반환하기 전에 반대 작업을 수행해야합니다. DataGrid 값을 다시 반환 할 변수에 복사합니다.

또는 바인딩 가능한 ArrayCollection 변수를 사용하여 DataGrid가 사용자에 의해 업데이트 될 때 ArrayCollection 변수가 이미 업데이트되어 다시 ColdFusion으로 되돌릴 수 있습니다.

0

나는 비슷한 것을 할 필요가 있었고, 나는 액션 스크립트에서 "데이터 세트"객체와 서로 맵핑 할 유사한 CFC를 만드는 것이 좋았다. flex에서, 원격 메소드를 호출하여 actionscript 객체를 전달한 다음 CF 측에서 cfc로 변환됩니다.

[RemoteClass(alias = "model.DataSet")] **//maps to the CFC**  
[Bindable] 
public class DataSetVO 
{  

    public var rows:Array; 

    public function DataSetVO() 
    { 

    } 

} 

CFC는 이와 유사합니다.확인 ActionScript 객체의 RemoteClass라는의 별명 세트를 일치하도록 별칭 속성을 설정해야합니다 : 플렉스처럼에서

<cfcomponent name="DataSet" alias="model.DataSet"> 
<cfproperty name="rows" type="array" /> 
</cfcomponent> 

데이터를 저장하는 CFC 방법은

<cffunction name="saveToFile" access="remote" returntype="numeric" hint=""> 
    <cfargument name="dataSet" type="model.GPDataSet" required="true" /> 
    <!--- do what you need to do to with arguments.dataSet to 
        save to a file, database, whatever ---> 
    <cfreturn 0 /> 
</cffunction> 

처럼 호출 할 수 있습니다 :

//make a remote call to save the grid 
//populate your VO with the contents of the grid, in this case I have an object 
//that gives me one, basically iterate over the dataprovider of the grid 
var myVO:DataSetVO = myDataSet.getAsVO(); 
//calling the remote CFC passing the VO that will be mapped to a CFC on the server 
cfsvc.saveToFile(myVO); 

복잡한 개체를 Flex에서 CF로 매핑하는 것은 다소 까다로울 수 있지만 일단 설정하면 매우 좋습니다.

이 기사는 도움이 될 수 있습니다

http://www.jeffryhouser.com/index.cfm/2007/10/9/Why-does-ColdFusion-return-a-CFC-to-Flex-as-a-generic-object

http://mxbase.blogspot.com/2008/07/passing-custom-objects-between-flex-and.html

관련 문제