RE: [flexcoders] Re: Flex Item Renderer using popup to edit datagrid - How to refresh datagrid?

2008-05-12 Thread Tracy Spratt
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:[EMAIL PROTECTED] On
Behalf Of web2mmac
Sent: Monday, May 12, 2008 10:07 AM
To: flexcoders@yahoogroups.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 
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   
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

RE: [flexcoders] Re: Flex Item Renderer using popup to edit datagrid - How to refresh datagrid?

2008-05-12 Thread Tracy Spratt
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