Are you getting your updated value from the pop-up back into the item
renderer?  Are you assigning the changed value to the item's appropriate
property in the renderer?

 

If so, then you may need to call dp_ac.itemUpdated(item) to make the DG
refresh.  Do that in the renderer through the listData object, or by
using Application.application to reach the main app's scope, where the
dg_ac var lives.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of web2mmac
Sent: Monday, May 12, 2008 1:55 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Flex Item Renderer using popup to edit
datagrid - How to refresh datagrid?

 

Tracy,
That is my question. I am not able to communicate back to the main
app due to the item renderer calling the popup page. Once the popup
closes, the array used to bind to the main app datagrid is updated,
but the datagrid in the main app does not get updated.

Thanks,
Mary
--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> That is too much unformatted code for me to analyze from scratch.
> 
> 
> 
> In your pop-up, how are you updating the "dp_ac" in the main app?
> 
> 
> 
> Tracy
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of web2mmac
> Sent: Monday, May 12, 2008 10:07 AM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Re: Flex Item Renderer using popup to edit
> datagrid - How to refresh datagrid?
> 
> 
> 
> Hi Tim,
> I understand what you said, but I am having trouble communicating
> back to the main dataGrid (myADG). Simply updating the dataProvider in
> the following code is not working! Here is the code... 
> Any help with this would be appreciated! Thanks!
> Mary
> 
> testItemRenderer.mxml...
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
> creationComplete="initapp()" layout="absolute">
> <mx:Script source="as/EditDataMain.as" />
> <mx:RemoteObject id="myService"
> destination="ColdFusion"
> 
> source="FB3.testItemRenderer.src.myComponents.myService" 
> 
> showBusyCursor="true"> 
> 
> <mx:method name="getAllRcds" result="getAllRcds_Result(event)"
> fault="Alert.show(event.fault.message)" />
> </mx:RemoteObject> 
> <mx:AdvancedDataGrid id="myADG" dataProvider="{dp_ac}"
> dataChange="getAllRcds()"
> width="100%" height="100%">
> 
> <mx:columns>
> <mx:AdvancedDataGridColumn dataField="name"/>
> <mx:AdvancedDataGridColumn dataField="countryregioncode" />
> <mx:AdvancedDataGridColumn dataField="group"/>
> <mx:AdvancedDataGridColumn dataField="salesytd"/>
> <mx:AdvancedDataGridColumn dataField="saleslastyear"/> 
> <mx:AdvancedDataGridColumn dataField="costytd"/>
> <mx:AdvancedDataGridColumn dataField="costlastyear"/> 
> <mx:AdvancedDataGridColumn fontSize="10" width="50" id="EditEvent" 
> headerText="Edit" itemRenderer="EditEventsRenderer" /> 
> </mx:columns>
> 
> EditDataMain.as...
> // ActionScript file
> import flash.events.Event;
> 
> import mx.collections.ArrayCollection;
> import mx.controls.AdvancedDataGrid;
> import mx.controls.Alert;
> import mx.managers.PopUpManager;
> import mx.rpc.events.ResultEvent;
> 
> import myComponents.editevents_tw; 
> 
> [Bindable]
> private var Territoryid:int; 
> [Bindable]
> private var dp_ac:ArrayCollection; 
> 
> [Bindable]
> public var pop:editevents_tw;
> 
> [Bindable]
> public var territoryid:Number;
> [Bindable]
> public var countryregioncode:String;
> [Bindable]
> public var group:String;
> [Bindable]
> public var salesytd:Number; 
> [Bindable]
> public var saleslastyear:Number; 
> [Bindable]
> public var costytd:Number; 
> [Bindable]
> public var costlastyear:Number; 
> 
> public function initapp():void{
> getAllRcds(); 
> }
> public function getAllRcds_Result(event:ResultEvent):void {
> dp_ac = new ArrayCollection;
> dp_ac = event.result as ArrayCollection;
> if (dp_ac.length == 0){
> Alert.show("No events found for selected date.")
> } 
> 
> 
> } 
> 
> public function getAllRcds():void{
> myService.getAllRcds(); 
> }
> //Edit Popup window
> public function editevents_popup(data:Object):void 
> { 
> // Create the pop-up and cast the return value of the createPopUp()
> // Method to the editevents custom component.
> 
> /* var message:String = '';
> message = 'territoryid ' + data.territoryid + '\n'; 
> message += 'countryregioncode ' + data.countryregioncode + '\n';
> message += 'group ' + data.group + '\n';
> message += 'salesytd ' + data.salesytd + '\n'; 
> message += 'sales last year ' + data.saleslastyear + '\n'; 
> message += 'costytd ' + data.costytd + '\n'; 
> message += 'cost last year ' + data.costlastyear + '\n'; 
> 
> Alert.show(message);*/ 
> 
> pop =editevents_tw(PopUpManager.createPopUp(this,editevents_tw,
> true));
> 
> // Set TitleWindow properties.
> pop.title="Edit an Event:";
> pop.iname.text=data.territoryid; 
> // pop.textitineraryid=data.itineraryid; 
> pop.rg.text=data.countryregioncode;
> pop.gr.text=data.group;
> pop.sytd.text=data.salesytd;
> pop.sly.text=data.saleslastyear;
> pop.cytd.text=data.costytd;
> pop.cly.text=data.costlastyear; 
> /* pop.nm.text=data.Name; */ 
> 
> pop.showCloseButton=true;
> 
> // Set the event listeners for the editevents component.
> pop.addEventListener("close", editevents_removeMe);
> pop["saveBtn"].addEventListener("click", editevents_submitData); 
> pop["deleteBtn"].addEventListener("click", editevents_removeMe); 
> pop["cancelButton"].addEventListener("click",
> editevents_removeMe); 
> }
> 
> public function editevents_submitData(event:Event):void 
> {
> 
> // radioedit.selected = 'false';
> data.countryregioncode=pop.rg.text;
> data.group=pop.gr.text;
> data.salesytd=pop.sytd.text;
> data.saleslastyear=pop.sly.text;
> data.costytd=pop.cytd.text;
> data.costlastyear=pop.cly.text; 
> PopUpManager.removePopUp(pop);
> }
> 
> // Cancel button click event listener.
> public function editevents_removeMe(event:Event):void 
> { 
> PopUpManager.removePopUp(pop);
> } 
> 
> 
> EditEventsRenderer.mxml...
> <?xml version="1.0"?>
> <!-- EditEventsRenderer.mxml -->
> 
> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > " >

> <mx:Script source="as/EditDataMain.as" /> 
> 
> 
> <mx:RemoteObject id="myService"
> destination="ColdFusion"
> 
> source="FB3.testItemRenderer.src.myComponents.myService" 
> 
> showBusyCursor="true"> 
> 
> <mx:method name="getAllRcds" result="getAllRcds_Result(event)"
> fault="Alert.show(event.fault.message)" />
> </mx:RemoteObject> 
> <mx:ControlBar width="32" horizontalAlign="center"
> verticalAlign="middle" height="19">
> <mx:Button id="eventedit" click="editevents_popup(this.data);" 
> width="14" height="13"/>
> </mx:ControlBar>
> 
> </mx:VBox>
> Editevents_tw.mxml...
> <?xml version="1.0"?>
> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
> showCloseButton="true" width="480" 
> creationComplete="initeditevents();" borderAlpha="1" height="270"
> borderColor="#CC6600" 
> alpha="0.76" backgroundAlpha="1.0" backgroundColor="#ffffff"
> title="Edit Event:" 
> fontFamily="Arial" fontSize="10" defaultButton="{cancelButton}">
> <mx:Script source="../as/EditDataMain.as" /> 
> 
> <mx:Script>
> <![CDATA[
> 
> public function initeditevents():void
> {
> // initialize here 
> 
> } 
> public function EventUpdate_Result(event:ResultEvent):void { 
> Alert.show("Itinerary Planner updated.","Alert"); 
> } 
> 
> 
> public function EvntDelete_Result(event:ResultEvent):void {
> 
> /* nm = null; */
> rg= null;
> gr = null;
> sytd = null;
> sly = null;
> cytd = null;
> cly = null;
> Alert.show("Item updated.","Alert"); 
> //refresh to catch changes made
> 
> /* var tourl:String = ""; 
> tourl += "http://";; 
> var u:URLRequest = new URLRequest(tourl); 
> navigateToURL(u, "_self"); */ 
> 
> } 
> public function EventUpdate():void {
> 
> 
> /* var message = '';
> message = 'Region' + rg + '\n'; 
> 
> Alert.show(message); */
> var hiname:int = int(iname.text);
> var hrg:String = rg.text;
> var hgr:String = gr.text;
> var hsytd:int = int(sytd.text);
> var hsly:int = int(sly.text); 
> var hcytd:int = int(cytd.text);
> var hcly:int = int(cly.text); 
> 
> myService.EvntUpdate(hiname,hrg,hgr,hsytd,hsly,hcytd,hcly,hcly);
> myService.getAllRcds(); 
> //refresh to catch changes made
> /* var tourl:String = ""; 
> tourl += "http://";; 
> var u:URLRequest = new URLRequest(tourl); 
> navigateToURL(u, "_self"); */ 
> }
> 
> public function EvntDelete():void {
> /* hitineraryid = parseInt(iname.text); 
> myService.EvntDelete(hitineraryid); */ 
> } 
> 
> ]]>
> </mx:Script>
> <mx:RemoteObject id="myService"
> destination="ColdFusion"
> 
> source="FB3.testItemRenderer.src.myComponents.myService" 
> 
> showBusyCursor="true"> 
> 
> <mx:method name="getAllRcds" result="getAllRcds_Result(event)"
> fault="Alert.show(event.fault.message)" />
> </mx:RemoteObject> 
> 
> <mx:Form id="acc_1_page_3" label="Edit Event:" height="186"
> width="420">
> 
> <mx:FormItem>
> <mx:VBox>
> 
> <mx:HBox>
> <mx:Label text="territoryid" /> 
> <mx:Label id="iname" text="{territoryid}" /> 
> 
> <mx:Label text="region" />
> <mx:TextInput id="rg" text="{countryregioncode}" /> 
> 
> <mx:Label text="group" /> 
> <mx:TextInput id="gr" text="{group}" />
> </mx:HBox>
> <mx:HBox> 
> <mx:Label text="sales ytd" />
> <mx:TextInput id="sytd" text="{salesytd}" />
> 
> <mx:Label text="sales ly" />
> <mx:TextInput id="sly" text="{saleslastyear}" /> 
> </mx:HBox>
> <mx:HBox> 
> <mx:Label text="cost ytd" />
> <mx:TextInput id="cytd" text="{costytd}" />
> 
> <mx:Label text="cost ly" />
> <mx:TextInput id="cly" text="{costlastyear}" /> 
> </mx:HBox>
> 
> </mx:VBox>
> </mx:FormItem> 
> 
> <mx:FormItem > 
> <mx:HBox>
> <mx:Button id="saveBtn" label="Save/Update"
> click="EventUpdate();" />
> <mx:Button id="deleteBtn" label="Delete"
> click="EvntDelete();" /> 
> </mx:HBox> 
> </mx:FormItem>
> </mx:Form>
> <mx:HBox height="50%" horizontalAlign="center" width="100%"
> verticalAlign="middle">
> <mx:Button id="cancelButton" label="Cancel"/>
> </mx:HBox> 
> </mx:TitleWindow>
> myService.cfc ...
> <cfcomponent>
> 
> <cffunction name="recordlog" access="remote" returntype="string">
> <cfargument name="input" type="any"> 
> <cffile action="append"
> file="c:\inetpub\wwwroot\FB3\testItemRenderer\logs\log.txt"
> addnewline="yes" output="#arguments.input#">
> <cfreturn>
> </cffunction> 
> 
> <cffunction name="getAllRcds" access="remote" returntype="query">
> <cftry>
> <cfquery name="rs1" datasource="AdventureWorks">
> SELECT [TerritoryID]
> ,[Name]
> ,[CountryRegionCode]
> ,[Group]
> ,[SalesYTD]
> ,[SalesLastYear]
> ,[CostYTD]
> ,[CostLastYear]
> ,[rowguid]
> ,[ModifiedDate]
> FROM [AdventureWorks].[Sales].[SalesTerritory] 
> </cfquery>
> 
> <cfreturn rs1>
> 
> <cfcatch type="any">
> <cfscript>
> recordlog("#cfcatch.detail# in function getALLEvents<br>");
> </cfscript>
> </cfcatch>
> </cftry> 
> 
> </cffunction>
> 
> <cffunction name="addItinerary" access="remote" returntype="numeric"> 
> <cfargument name="TerritoryID" type="numeric">
> <cfargument name="CountryRegionCode" type="string" required="yes">
> <cfargument name="Group" type="string" required="yes">
> <cfargument name="SalesYTD" type="numeric" required="yes">
> <cfargument name="SalesLastYear" type="numeric" required="yes">
> <cfargument name="CostYTD" type="numeric" required="yes">
> <cfargument name="CostLastYear" type="numeric" required="yes"> 
> 
> <!--- <cfscript>
> 
>
recordlog("addItinerary<br>#arguments.Name#<br>#arguments.CountryRegionC
>
ode#<br>#arguments.Group#<br>#arguments.SalesYTD#<br>#arguments.SalesLas
> tYear#<br>#arguments.CostYTD#<br>#arguments.CostLastYear#
> in function addItinerary<br>");
> </cfscript> ---> 
> <cftry>
> 
> <cfquery name="ins" datasource="AdventureWorks"> 
> INSERT INTO [AdventureWorks].[Sales].[SalesTerritory]
> ([CountryRegionCode]
> ,[Group]
> ,[SalesYTD]
> ,[SalesLastYear]
> ,[CostYTD]
> ,[CostLastYear]
> ,[ModifiedDate])
> VALUES
> (#arguments.CountryRegionCode#
> ,#arguments.Group#
> ,#arguments.SalesYTD#
> ,#arguments.SalesLastYear#
> ,#arguments.CostYTD#
> ,#arguments.CostLastYear#
> ,#now()#)
> </cfquery>
> 
> <cfreturn 1>
> 
> <cfcatch type="any">
> <cfscript>
> 
>
recordlog("2#cfcatch.detail#<br>#arguments.Name#<br>#arguments.CountryRe
>
gionCode#<br>#arguments.Group#<br>#arguments.SalesYTD#<br>#arguments.Sal
> esLastYear#<br>#arguments.CostYTD#<br>#arguments.CostLastYear#
> in function addItinerary<br>");
> </cfscript>
> </cfcatch>
> 
> </cftry>
> 
> </cffunction> 
> 
> 
> <cffunction name="EvntUpdate" access="remote" returntype="void">
> <cfargument name="TerritoryID" type="string" required="yes">
> <cfargument name="CountryRegionCode" type="string" required="yes">
> <cfargument name="Group" type="string" required="yes">
> <cfargument name="SalesYTD" type="string" required="yes">
> <cfargument name="SalesLastYear" type="string" required="yes">
> <cfargument name="CostYTD" type="string" required="yes">
> <cfargument name="CostLastYear" type="string" required="yes"> 
> <!--- <cfscript>
> 
>
recordlog("<br>#arguments.TerritoryID#<br>#arguments.CountryRegionCode#<
>
br>#arguments.Group#<br>#arguments.SalesYTD#<br>#arguments.SalesLastYear
> #<br>#arguments.CostYTD#<br>#arguments.CostLastYear#
> <br>Just in function updEvent<br>"); 
> </cfscript> --->
> 
> <cftry>
> 
> <cfquery name="upd" datasource="AdventureWorks">
> UPDATE [AdventureWorks].[Sales].[SalesTerritory]
> SET [CountryRegionCode] = '#arguments.CountryRegionCode#',
> [Group] = '#arguments.Group#',
> [SalesYTD] = #arguments.SalesYTD#,
> [SalesLastYear] = #arguments.SalesLastYear#,
> [CostYTD] = #arguments.CostYTD#,
> [CostLastYear] = #arguments.CostLastYear#
> WHERE territoryid = #arguments.TerritoryID# 
> </cfquery> 
> <cfcatch type="any">
> <cfscript>
> recordlog("#cfcatch.detail#<br>terr #arguments.territoryid#<br>reg
> #arguments.CountryRegionCode#<br>grp #arguments.Group#<br>sales ytd
> #arguments.SalesYTD#<br>sales ly #arguments.SalesLastYear#<br>cost ytd
> #arguments.CostYTD#<br>cost ly #arguments.CostLastYear# <br>in
> function updEvent<br>");
> </cfscript>
> </cfcatch>
> </cftry>
> 
> 
> 
> <cfreturn>
> </cffunction>
> 
> <cffunction name="EvntDelete" access="remote" returntype="void">
> <cfargument name="territoryid" type="numeric">
> 
> <cftry>
> 
> <cfquery name="dd" datasource="AdventureWorks">
> DELETE FROM [AdventureWorks].[Sales].[SalesTerritory]
> WHERE territoryid = #arguments.territoryid# 
> </cfquery> 
> 
> <cfcatch type="any">
> <cfscript>
> recordlog("#cfcatch.detail#<br>#arguments.territoryid#<br>in
> function EvntDelete<br>");
> </cfscript>
> </cfcatch>
> </cftry>
> 
> 
> <cfreturn>
> </cffunction>
> 
> </cfcomponent> 
> 
> --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> , "Tim Hoff" <TimHoff@> wrote:
> >
> > Hi Mary,
> > 
> > Typically, when you make an update to a DB, you will want to refresh

> > the dataGrid's dataProvider with the updated data from the DB. This 
> > usually means either returning an updated object in the result of an

> > update service call, or making an additional call to get the data 
> > from the DB; after the DB object has been successfully updated. If 
> > you use binding for the dataGrid's dataProvider, you won't have to 
> > communicate with the dataGrid at all. Just refresh the dataProvider 
> > collection and Flex will handle the rest for you.
> > 
> > -TH
> > 
> > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com> , "web2mmac" <web2mmac@> wrote:
> > >
> > > Hi,
> > > I have a Flex app that has a datagrid with an Item Renderer. The
> > > Item Renderer displays a button the user can click on to edit the 
> > row
> > > of data. When the user presses the "save" button the data is
updated
> > > in the database. 
> > > 
> > > My question is because of the layers (Item Renderer and Popup), I 
> > am
> > > having trouble sending a message to the datagrid to tell it to 
> > refresh.
> > > 
> > > Does anyone have any idea how I could do that? I have the code in 
> > a
> > > zip file and it used AdventureWorks db, if anyone would like a
copy,
> > > let me know.
> > > 
> > > Thanks,
> > > 
> > > Mary McDonald
> > >
> >
>

 

Reply via email to