2009-03-12 12 views
1

ColdFusionのCFCを介して他のフォームフィールドと一緒に保存する必要がある編集可能なデータグリッドがあります。Flex:CFCで編集可能なデータグリッドを保存

基本的な目的は、最初の列を構成する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のFlexを知っているが、もし、あなたが決定していませんそれらを一度にすべて保存するか、何らかの「保存」アクションまたは「送信」アクションで保存しますか?

これらを一度に保存する場合は、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

私は同様のことをする必要がありました。私はそれがうまくいけば、actionscriptに "データセット"オブジェクトを作成し、お互いにマップする類似の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> 

にフレックスからの呼び出しが似ている

<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> 

のようにデータを保存するためにCFCメソッドをすることができ:

//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

関連する問題