1

私は編集可能なデータグリッドを持っており、ColdFusionのCFCを介して他のフォームフィールドと一緒に保存できるようにする必要があります。

基本的に目的は、ROを介して取得された多くの場所があり、最初の列を構成し、残りの列はデータのタイプ、つまり人口統計、クライアントのメモ、予定などです。ユーザーがチェックボックスの各チェックボックスをオンにすることを目的としています。グリッドは、データの種類をそれらの場所と共有して満足していることを示します。場所が変わる可能性があるため、この方法で行う必要があります。これにより、時間の経過とともに2つまたは4つ以上になる可能性があります。

コードはこれまでのところ実行され、見栄えは良いですが、節約ビットが私を狂わせています!! 助けてください。

よろしくお願いします:)コード(正気のために省略)は以下のとおりです:

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

3 に答える 3

1

あなたがしたいことは、DataGrid のコンテンツ全体をフォーム データの残りのメンバーとして返すことです。私はまだ Flex を学んでいますが、AMF を使用しているため、自動的に ArrayCollection から Query に変換されると思います。

DataGrid に dataProvider 属性を使用していないため、イベントinitから呼び出している関数で ArrayCollection オブジェクトを DataGrid にバインドしていると仮定します。creationCompleteその場合、フォーム データをサーバーに返す前に、反対のことを行う必要があります。DataGrid の値を、返す変数にコピーして戻します。

または、バインド可能な ArrayCollection 変数を使用して、DataGrid がユーザーによって更新されたときに、ArrayCollection 変数が既に更新されているので、単純に ColdFusion に戻すことができます。

于 2009-03-13T15:45:19.147 に答える
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>

データを保存する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>

flex からの呼び出しは次のようになります。

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

于 2009-09-30T18:17:04.950 に答える
0

Flex の CF はわかりませんが、一度にすべてを保存するか、何らかの「保存」または「送信」アクションで保存するかを決定しましたか?

すべてを一度に保存する場合は、Flex での ColdFusion クエリの繰り返しに関するこの投稿が役立つ場合があります。

それ以外の場合は、各セルの onChange イベントにリスナーを配置し、リアルタイムで書き込みます。

于 2009-03-13T00:43:03.353 に答える