편집 가능한 DataGrid가 있고 모든 편집이 완료된 후 데이터베이스에 삽입하기 위해 CFC를 통해 데이터베이스로 다시 보내야합니다. . 배열 컬렉션을 cfdump로 덤프하면 항목과 구조체가있는 배열이 있지만 각각을 통해 "루프"하고 DB에 삽입하는 방법을 이해할 수 없다는 것을 알 수 있습니다.데이터베이스에 삽입하기 위해 편집 된 Flex DataGrid를 CFC에 전달하는 방법
실제로 작동하는 서적이 거의없는 것 같습니다! 내 MXML과 CFC는 아래에 있지만 "클래스가있는 ColdFusion.runtime.Array 유형의 스칼라 변수를 멤버가있는 구조로 역 참조하려고했습니다."라는 오류가 표시됩니다. - 어떤이 좋은
모든 도움을 많이 감사합니다 - 감사
[Bindable]
private var getconsent:ArrayCollection = new ArrayCollection([
{LocationName:'Service A', Contact: 'Bob Jones' },
{LocationName:'Service B', Contact: 'Jane Smith' },
{LocationName:'Service c', Contact: 'Doug Johnson' },
{LocationName:'Service d', Contact: 'John Jackson'}
]);
public function send():void {
cfdata.sendData(getconsent.source);
}
public function send_Result(event:ResultEvent):void {
Alert.show('ok');
}
public function send_Fault(event:FaultEvent):void {
Alert.show(event.fault.message);
}
]]>
</mx:Script>
<mx:RemoteObject
id="cfdata"
showBusyCursor="true"
destination="ColdFusion"
source="buildtest.test2">
<mx:method name="sendData" result="send_Result(event)" fault="send_Fault(event)" />
</mx:RemoteObject>
<mx:DataGrid id="myGrid"
dataProvider="{getconsent}" editable="true" >
<mx:columns>
<mx:DataGridColumn dataField="LocationName" width="150"
editable="false"/>
<mx:DataGridColumn dataField="Contact" width="150" />
</mx:columns>
</mx:DataGrid>
<mx:Button label="Update DB" click="send()"/>
<cfcomponent displayname="sendData" output="false" >
<cffunction name="sendData" access="remote" output="no" returnType="void" required="yes" >
<cfargument name="getconsent" type="any" required="true">
<cfloop from="1" to="#ArrayLen(getconsent.dataprovider)#" index="i">
<cfquery name="clientconsent" datasource="gvr">
INSERT INTO ClientConsent"
(Location)
VALUES
('#getconsent.dataprovider.LocationName[i]#')
</cfquery>
</cfloop>
</cffunction>
</cfcomponent>
배열 1 개 구조체 연락 밥 존스
LocationName 서비스 및 A
012 당신이 CF9를 사용하는 경우 3,516,이 807D204F-A315-7D78-C745-BAD78087CB28에게
2 struct
Contact Jane Smith
LocationName Service B
mx_internal_uid EAA43EF4-A7EA-82C9-5F3C-BAD780D7FD6F
3 struct
Contact Doug Johnson
LocationName Service c
mx_internal_uid 9768D6D2-8F97-5F4D-767C-BAD780D7B478
PLS 성능 이유 INSIDE cfquery 등 다른 방법은 주위를 CFLOOP 사용 . :) – Henry
Henry의 의견을 확대하기 위해 현재 각 쿼리에 대해 데이터베이스에 대한 새로운 연결을 만들고 있습니다. 루프를 안에 넣으면 하나의 연결 만 만들어집니다. 이것은 사용중인 데이터 소스 드라이버가 여러 명령 (세미콜론으로 구분)을 게시 할 수 있다고 가정합니다. –