PDA

View Full Version : itemRenderer changing application currentState?


7humbs
11-11-2008, 02:06 PM
Hi,
I have an application and I'm trying to change the "state" via a click of a button in the dataGrid.

I've attached some of the code below (about 20 lines).

Thanks in advance to anyone that can help.



<mx:DataGridColumn editable="false" headerText="Daily - Report Names" dataField="link" textAlign="left" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:LinkButton click="handleClick()" label="{data.link}">
<mx:Script>
<![CDATA[
public function handleClick():void{
var url:URLRequest = new URLRequest(data.url);
navigateToURL(url,"_blank");
}
]]>
</mx:Script>
</mx:LinkButton>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn editable="false" headerText="Daily - Report Archives" dataField="link" textAlign="left" width="80">
<mx:itemRenderer>
<mx:Component>
<mx:Button buttonMode="true" useHandCursor="true" click="currentState='monthly';handleClick(data.archive_li nk)" textAlign="center" label="View {data.archive_button_label} archives" width="80">
<mx:Script>
<![CDATA[
[Bindable] public var archiveURL:String=null;
[Bindable] public var mySO:SharedObject;
[Bindable] public var welcomeMessage:String=null;

public function handleClick(archiveInfo:String):void{
//currentState='monthly';
archiveURL = archiveInfo;
storeDate();
//trace(archiveURL.toString());

var url:URLRequest = new URLRequest("archive_viewer.html");
navigateToURL(url,"_blank");
}

private function storeDate():void {
mySO = SharedObject.getLocal("mydata","/",false);
mySO.data.visitDate = new Date();
mySO.data.archiveLink = archiveURL;
mySO.flush();
}

private function deleteLSO():void {
// Deletes the SharedObject from the client machine.
// Next time they log in, they will be a 'first-timer'.
mySO.clear();
}
]]>
</mx:Script>
</mx:Button>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>

7humbs
11-11-2008, 03:19 PM
Never mind my problem has been answered. The solution was to add the following in front of the currentState='monthly': outerDocument.

click="outerDocument.currentState='monthly';"