You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mo...@comcast.net on 2014/12/01 15:20:26 UTC

Re: how to updateDisplayList() in custom headerRenderer? (help!)

Hello again, I haven't got any response and was just hoping I could entice someone to review my question below. 

The code implements a textbook method to update the client model when someone changes the text in a spark TextInput located in a header renderer. This works fine. I just need to know a textbook method to go the other direction -- that is, how to programmatically update the text in the TextInput? I'm sure there's some standard way to do this, but I can't figure it out. Any hints much appreciated. I've tried to copy all the relevant code below. 

----- Original Message -----

From: modjklist@comcast.net 
To: "users, apache" <us...@flex.apache.org> 
Sent: Saturday, November 29, 2014 7:12:47 PM 
Subject: how to updateDisplayList() in custom headerRenderer? 

I'm using 4.12 SDK and trying to update a headerRenderer that includes a TextInput. Things works fine when the component is initialized. But thereafter, when I change the model such that the text showing in the TextInput box should change, the text doesn't change. 

Can someone help me figure out how to programmatically refresh the header renderer TextInput text using function updateCondition() in file MyView.mxml below? 

I've tried create a temp IFactory for the header renderer, null the original one, then save the temp back to the original, but this didn't work. Also tried invalidateDisplayList() on myGrid (didn't work either). 

Here's MyHeaderRenderer.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<s:GridItemRenderer 
xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
xmlns:itemRenderers="com.example.views.itemRenderers.*"> 

<fx:Script> 
<![CDATA[ 
import mx.collections.ArrayCollection; 
import com.example.views.components.MyGrid; 

public function ti_focusOut():void { 
MyGrid(this.owner['parentDocument']).myCondition=Number(ti.text); 
MyGrid(this.owner['parentDocument']).dispatchEvent(new Event("myConditionChanged")); 
} 

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { 
if (this.owner['parentDocument'] && ti && MyGrid(this.owner['parentDocument']).myCondition) { 
ti.text=String(MyGrid(this.owner['parentDocument']).myCondition); 
} 
super.updateDisplayList(unscaledWidth,unscaledHeight); 
} 
]]> 
</fx:Script> 
<s:states> 
<s:State name="normal"/> 
</s:states> 
<s:TextInput id="ti" width="40" focusOut="ti_focusOut();"/> 
</s:GridItemRenderer> 


and here's MyGrid.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx"> 

<fx:Metadata> 
[Event(name="myConditionChanged", type="flash.events.Event")] 
</fx:Metadata> 

<fx:Script> 
<![CDATA[ 
... 
[Bindable] private var _myCondition:Number; 
public function set myCondition(value:Number):void { 
_myCondition=value; 
if (grid.columnHeaderGroup) { 
grid.columnHeaderGroup.layout.clearVirtualLayoutCache(); 
grid.columnHeaderGroup.invalidateDisplayList(); 
} 
grid.invalidateDisplayList(); 
} 
[Bindable] public function get myCondition():Number { 
return _myCondition; 
} 
... 
]]> 
</fx:Script> 

<s:DataGrid id="grid"> 
<s:columns> 
<s:ArrayList> 
<s:GridColumn .../> 
<s:GridColumn id="myColumn" dataField="myCond" headerRenderer="com.example.views.itemRenderers.MyHeaderRenderer"/> 
<s:GridColumn .../> 
</s:ArrayList> 
</s:columns> 
</s:DataGrid> 
</s:Group> 

and finally, here is MyView.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<views:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
xmlns:components="com.example.views.components.*"> 
... 
<fx:Script> 
<![CDATA[ 
private function updateCondition():void { 
myGrid.myCondition=newValue; 
// how to force refresh of TextInput in header renderer with newValue? 
} 
private function onChange():void { 
... 
} 
]]> 
</fx:Script> 
<components:MyGrid id="myGrid" myConditionChanged="onChange();"/> 
... 
</views:View> 


RE: AW: AW: how to updateDisplayList() in custom headerRenderer? (help!)

Posted by Frédéric THOMAS <we...@hotmail.com>.
Hi,
Don't know if it can help but what I used to do was to build the datagrid dynamically when a relative to the data-structure I received, setting the headers in the same time, then display this new instance at the place of the last one.

Frédéric THOMAS

> From: OKrueger@edscha.com
> To: users@flex.apache.org
> Subject: AW: AW: how to updateDisplayList() in custom headerRenderer? (help!)
> Date: Tue, 2 Dec 2014 11:45:58 +0000
> 
> I tried it also and also tried some other ways but nothing works. I've no idea how to get it working with an headerRenderer, sorry.
> Perhaps Alex could help?
> 
> Olaf
> 
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: modjklist@comcast.net [mailto:modjklist@comcast.net]
> Gesendet: Montag, 1. Dezember 2014 21:06
> An: users, apache
> Betreff: Re: AW: how to updateDisplayList() in custom headerRenderer? (help!)
> 
> Thanks Olaf,
> 
> I tried to implement by making a public bindable variable "myCondition" in the header renderer and then binding it to the TextInput text property (e.g. <s:TextInput text="{myCondition}".../>).
> 
> but I get the same results -- the variable myCondition is correctly transferred to the header renderer the FIRST time it is created, but after that, changes to variable myCondition in the main application do not show up in the header. Any idea what I'm doing wrong?
> 
> ----- Original Message -----
> 
> From: "Olaf Krüger" <OK...@edscha.com>
> To: "users, apache" <us...@flex.apache.org>
> Sent: Monday, December 1, 2014 6:59:35 AM
> Subject: AW: how to updateDisplayList() in custom headerRenderer? (help!)
> 
> If your question is "How to pass additional data to an item renderer" this could work for you:
> (Take a look at the links to understand how it works)
> 
> /**
> * Pass additional data to a Renderer
> *
> * @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/ClassFactory.html
> * @see http://stackoverflow.com/questions/528796/flex-sending-a-parameter-to-a-custom-itemrenderer
> */
> public static function createHeaderRenderer (renderer:Class, myCondition:Number):IFactory { var factory:ClassFactory = new ClassFactory(renderer); factory.properties = { myCondition: myCondition }; return factory; }
> 
> …
> <s:GridColumn headerRenderer="{createHeaderRenderer(MyHeaderRenderer, myCondition)}"/> …
> 
> 
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: modjklist@comcast.net [mailto:modjklist@comcast.net]
> Gesendet: Montag, 1. Dezember 2014 15:20
> An: users, apache
> Betreff: Re: how to updateDisplayList() in custom headerRenderer? (help!)
> 
> Hello again, I haven't got any response and was just hoping I could entice someone to review my question below.
> 
> The code implements a textbook method to update the client model when someone changes the text in a spark TextInput located in a header renderer. This works fine. I just need to know a textbook method to go the other direction -- that is, how to programmatically update the text in the TextInput? I'm sure there's some standard way to do this, but I can't figure it out. Any hints much appreciated. I've tried to copy all the relevant code below.
> 
> ----- Original Message -----
> 
> From: modjklist@comcast.net
> To: "users, apache" <us...@flex.apache.org>
> Sent: Saturday, November 29, 2014 7:12:47 PM
> Subject: how to updateDisplayList() in custom headerRenderer?
> 
> I'm using 4.12 SDK and trying to update a headerRenderer that includes a TextInput. Things works fine when the component is initialized. But thereafter, when I change the model such that the text showing in the TextInput box should change, the text doesn't change.
> 
> Can someone help me figure out how to programmatically refresh the header renderer TextInput text using function updateCondition() in file MyView.mxml below?
> 
> I've tried create a temp IFactory for the header renderer, null the original one, then save the temp back to the original, but this didn't work. Also tried invalidateDisplayList() on myGrid (didn't work either).
> 
> Here's MyHeaderRenderer.mxml:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <s:GridItemRenderer
> xmlns:fx="http://ns.adobe.com/mxml/2009"
> xmlns:s="library://ns.adobe.com/flex/spark"
> xmlns:mx="library://ns.adobe.com/flex/mx"
> xmlns:itemRenderers="com.example.views.itemRenderers.*">
> 
> <fx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
> import com.example.views.components.MyGrid;
> 
> public function ti_focusOut():void {
> MyGrid(this.owner['parentDocument']).myCondition=Number(ti.text);
> MyGrid(this.owner['parentDocument']).dispatchEvent(new Event("myConditionChanged")); }
> 
> override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { if (this.owner['parentDocument'] && ti && MyGrid(this.owner['parentDocument']).myCondition) { ti.text=String(MyGrid(this.owner['parentDocument']).myCondition);
> }
> super.updateDisplayList(unscaledWidth,unscaledHeight);
> }
> ]]>
> </fx:Script>
> <s:states>
> <s:State name="normal"/>
> </s:states>
> <s:TextInput id="ti" width="40" focusOut="ti_focusOut();"/> </s:GridItemRenderer>
> 
> 
> and here's MyGrid.mxml:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
> xmlns:s="library://ns.adobe.com/flex/spark"
> xmlns:mx="library://ns.adobe.com/flex/mx">
> 
> <fx:Metadata>
> [Event(name="myConditionChanged", type="flash.events.Event")] </fx:Metadata>
> 
> <fx:Script>
> <![CDATA[
> ...
> [Bindable] private var _myCondition:Number; public function set myCondition(value:Number):void { _myCondition=value; if (grid.columnHeaderGroup) { grid.columnHeaderGroup.layout.clearVirtualLayoutCache();
> grid.columnHeaderGroup.invalidateDisplayList();
> }
> grid.invalidateDisplayList();
> }
> [Bindable] public function get myCondition():Number { return _myCondition; } ...
> ]]>
> </fx:Script>
> 
> <s:DataGrid id="grid">
> <s:columns>
> <s:ArrayList>
> <s:GridColumn .../>
> <s:GridColumn id="myColumn" dataField="myCond" headerRenderer="com.example.views.itemRenderers.MyHeaderRenderer"/>
> <s:GridColumn .../>
> </s:ArrayList>
> </s:columns>
> </s:DataGrid>
> </s:Group>
> 
> and finally, here is MyView.mxml:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <views:View xmlns:fx="http://ns.adobe.com/mxml/2009"
> xmlns:s="library://ns.adobe.com/flex/spark"
> xmlns:mx="library://ns.adobe.com/flex/mx"
> xmlns:components="com.example.views.components.*">
> ...
> <fx:Script>
> <![CDATA[
> private function updateCondition():void { myGrid.myCondition=newValue; // how to force refresh of TextInput in header renderer with newValue?
> }
> private function onChange():void {
> ...
> }
> ]]>
> </fx:Script>
> <components:MyGrid id="myGrid" myConditionChanged="onChange();"/>
> ...
> </views:View>
> 
> 
> ________________________________
> 
> Edscha Holding GmbH
> Sitz der Gesellschaft: Remscheid
> Registergericht: Wuppertal, HRB 22889
> Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña, David Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz und Volker Weiss
> 
> Vertretungsberechtigt sind nur Geschäftsführer und schriftlich Bevollmächtigte.
> 
> Solely Managing Directors or employees with a written proxy have got power of representation.
> 
> Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien ist vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung, Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte informieren Sie in diesem Fall unverzüglich den Absender und löschen Sie die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem System. Vielen Dank.
> 
> The contents of this e-mail including any attachments are confidential and may be legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete this e-mail including any attachments from your system. Thank you.
> 
> 
> ________________________________
> 
> Edscha Holding GmbH
> Sitz der Gesellschaft: Remscheid
> Registergericht: Wuppertal, HRB 22889
> Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña, David Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz und Volker Weiss
> 
> Vertretungsberechtigt sind nur Geschäftsführer und schriftlich Bevollmächtigte.
> 
> Solely Managing Directors or employees with a written proxy have got power of representation.
> 
> Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien ist vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung, Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte informieren Sie in diesem Fall unverzüglich den Absender und löschen Sie die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem System. Vielen Dank.
> 
> The contents of this e-mail including any attachments are confidential and may be legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete this e-mail including any attachments from your system. Thank you.
 		 	   		  

AW: AW: how to updateDisplayList() in custom headerRenderer? (help!)

Posted by Krüger, Olaf <OK...@edscha.com>.
I tried it also and also tried some other ways but nothing works. I've no idea how to get it working with an headerRenderer, sorry.
Perhaps Alex could help?

Olaf




-----Ursprüngliche Nachricht-----
Von: modjklist@comcast.net [mailto:modjklist@comcast.net]
Gesendet: Montag, 1. Dezember 2014 21:06
An: users, apache
Betreff: Re: AW: how to updateDisplayList() in custom headerRenderer? (help!)

Thanks Olaf,

I tried to implement by making a public bindable variable "myCondition" in the header renderer and then binding it to the TextInput text property (e.g. <s:TextInput text="{myCondition}".../>).

but I get the same results -- the variable myCondition is correctly transferred to the header renderer the FIRST time it is created, but after that, changes to variable myCondition in the main application do not show up in the header. Any idea what I'm doing wrong?

----- Original Message -----

From: "Olaf Krüger" <OK...@edscha.com>
To: "users, apache" <us...@flex.apache.org>
Sent: Monday, December 1, 2014 6:59:35 AM
Subject: AW: how to updateDisplayList() in custom headerRenderer? (help!)

If your question is "How to pass additional data to an item renderer" this could work for you:
(Take a look at the links to understand how it works)

/**
* Pass additional data to a Renderer
*
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/ClassFactory.html
* @see http://stackoverflow.com/questions/528796/flex-sending-a-parameter-to-a-custom-itemrenderer
*/
public static function createHeaderRenderer (renderer:Class, myCondition:Number):IFactory { var factory:ClassFactory = new ClassFactory(renderer); factory.properties = { myCondition: myCondition }; return factory; }

…
<s:GridColumn headerRenderer="{createHeaderRenderer(MyHeaderRenderer, myCondition)}"/> …





-----Ursprüngliche Nachricht-----
Von: modjklist@comcast.net [mailto:modjklist@comcast.net]
Gesendet: Montag, 1. Dezember 2014 15:20
An: users, apache
Betreff: Re: how to updateDisplayList() in custom headerRenderer? (help!)

Hello again, I haven't got any response and was just hoping I could entice someone to review my question below.

The code implements a textbook method to update the client model when someone changes the text in a spark TextInput located in a header renderer. This works fine. I just need to know a textbook method to go the other direction -- that is, how to programmatically update the text in the TextInput? I'm sure there's some standard way to do this, but I can't figure it out. Any hints much appreciated. I've tried to copy all the relevant code below.

----- Original Message -----

From: modjklist@comcast.net
To: "users, apache" <us...@flex.apache.org>
Sent: Saturday, November 29, 2014 7:12:47 PM
Subject: how to updateDisplayList() in custom headerRenderer?

I'm using 4.12 SDK and trying to update a headerRenderer that includes a TextInput. Things works fine when the component is initialized. But thereafter, when I change the model such that the text showing in the TextInput box should change, the text doesn't change.

Can someone help me figure out how to programmatically refresh the header renderer TextInput text using function updateCondition() in file MyView.mxml below?

I've tried create a temp IFactory for the header renderer, null the original one, then save the temp back to the original, but this didn't work. Also tried invalidateDisplayList() on myGrid (didn't work either).

Here's MyHeaderRenderer.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:itemRenderers="com.example.views.itemRenderers.*">

<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import com.example.views.components.MyGrid;

public function ti_focusOut():void {
MyGrid(this.owner['parentDocument']).myCondition=Number(ti.text);
MyGrid(this.owner['parentDocument']).dispatchEvent(new Event("myConditionChanged")); }

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { if (this.owner['parentDocument'] && ti && MyGrid(this.owner['parentDocument']).myCondition) { ti.text=String(MyGrid(this.owner['parentDocument']).myCondition);
}
super.updateDisplayList(unscaledWidth,unscaledHeight);
}
]]>
</fx:Script>
<s:states>
<s:State name="normal"/>
</s:states>
<s:TextInput id="ti" width="40" focusOut="ti_focusOut();"/> </s:GridItemRenderer>


and here's MyGrid.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">

<fx:Metadata>
[Event(name="myConditionChanged", type="flash.events.Event")] </fx:Metadata>

<fx:Script>
<![CDATA[
...
[Bindable] private var _myCondition:Number; public function set myCondition(value:Number):void { _myCondition=value; if (grid.columnHeaderGroup) { grid.columnHeaderGroup.layout.clearVirtualLayoutCache();
grid.columnHeaderGroup.invalidateDisplayList();
}
grid.invalidateDisplayList();
}
[Bindable] public function get myCondition():Number { return _myCondition; } ...
]]>
</fx:Script>

<s:DataGrid id="grid">
<s:columns>
<s:ArrayList>
<s:GridColumn .../>
<s:GridColumn id="myColumn" dataField="myCond" headerRenderer="com.example.views.itemRenderers.MyHeaderRenderer"/>
<s:GridColumn .../>
</s:ArrayList>
</s:columns>
</s:DataGrid>
</s:Group>

and finally, here is MyView.mxml:

<?xml version="1.0" encoding="utf-8"?>
<views:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="com.example.views.components.*">
...
<fx:Script>
<![CDATA[
private function updateCondition():void { myGrid.myCondition=newValue; // how to force refresh of TextInput in header renderer with newValue?
}
private function onChange():void {
...
}
]]>
</fx:Script>
<components:MyGrid id="myGrid" myConditionChanged="onChange();"/>
...
</views:View>


________________________________

Edscha Holding GmbH
Sitz der Gesellschaft: Remscheid
Registergericht: Wuppertal, HRB 22889
Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña, David Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz und Volker Weiss

Vertretungsberechtigt sind nur Geschäftsführer und schriftlich Bevollmächtigte.

Solely Managing Directors or employees with a written proxy have got power of representation.

Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien ist vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung, Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte informieren Sie in diesem Fall unverzüglich den Absender und löschen Sie die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem System. Vielen Dank.

The contents of this e-mail including any attachments are confidential and may be legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete this e-mail including any attachments from your system. Thank you.


________________________________

Edscha Holding GmbH
Sitz der Gesellschaft: Remscheid
Registergericht: Wuppertal, HRB 22889
Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña, David Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz und Volker Weiss

Vertretungsberechtigt sind nur Geschäftsführer und schriftlich Bevollmächtigte.

Solely Managing Directors or employees with a written proxy have got power of representation.

Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien ist vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung, Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte informieren Sie in diesem Fall unverzüglich den Absender und löschen Sie die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem System. Vielen Dank.

The contents of this e-mail including any attachments are confidential and may be legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete this e-mail including any attachments from your system. Thank you.

Re: AW: how to updateDisplayList() in custom headerRenderer? (help!)

Posted by mo...@comcast.net.
Thanks Olaf, 

I tried to implement by making a public bindable variable "myCondition" in the header renderer and then binding it to the TextInput text property (e.g. <s:TextInput text="{myCondition}".../>). 

but I get the same results -- the variable myCondition is correctly transferred to the header renderer the FIRST time it is created, but after that, changes to variable myCondition in the main application do not show up in the header. Any idea what I'm doing wrong? 

----- Original Message -----

From: "Olaf Krüger" <OK...@edscha.com> 
To: "users, apache" <us...@flex.apache.org> 
Sent: Monday, December 1, 2014 6:59:35 AM 
Subject: AW: how to updateDisplayList() in custom headerRenderer? (help!) 

If your question is "How to pass additional data to an item renderer" this could work for you: 
(Take a look at the links to understand how it works) 

/** 
* Pass additional data to a Renderer 
* 
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/ClassFactory.html 
* @see http://stackoverflow.com/questions/528796/flex-sending-a-parameter-to-a-custom-itemrenderer 
*/ 
public static function createHeaderRenderer (renderer:Class, myCondition:Number):IFactory 
{ 
var factory:ClassFactory = new ClassFactory(renderer); 
factory.properties = { myCondition: myCondition }; 
return factory; 
} 

… 
<s:GridColumn headerRenderer="{createHeaderRenderer(MyHeaderRenderer, myCondition)}"/> 
… 





-----Ursprüngliche Nachricht----- 
Von: modjklist@comcast.net [mailto:modjklist@comcast.net] 
Gesendet: Montag, 1. Dezember 2014 15:20 
An: users, apache 
Betreff: Re: how to updateDisplayList() in custom headerRenderer? (help!) 

Hello again, I haven't got any response and was just hoping I could entice someone to review my question below. 

The code implements a textbook method to update the client model when someone changes the text in a spark TextInput located in a header renderer. This works fine. I just need to know a textbook method to go the other direction -- that is, how to programmatically update the text in the TextInput? I'm sure there's some standard way to do this, but I can't figure it out. Any hints much appreciated. I've tried to copy all the relevant code below. 

----- Original Message ----- 

From: modjklist@comcast.net 
To: "users, apache" <us...@flex.apache.org> 
Sent: Saturday, November 29, 2014 7:12:47 PM 
Subject: how to updateDisplayList() in custom headerRenderer? 

I'm using 4.12 SDK and trying to update a headerRenderer that includes a TextInput. Things works fine when the component is initialized. But thereafter, when I change the model such that the text showing in the TextInput box should change, the text doesn't change. 

Can someone help me figure out how to programmatically refresh the header renderer TextInput text using function updateCondition() in file MyView.mxml below? 

I've tried create a temp IFactory for the header renderer, null the original one, then save the temp back to the original, but this didn't work. Also tried invalidateDisplayList() on myGrid (didn't work either). 

Here's MyHeaderRenderer.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<s:GridItemRenderer 
xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
xmlns:itemRenderers="com.example.views.itemRenderers.*"> 

<fx:Script> 
<![CDATA[ 
import mx.collections.ArrayCollection; 
import com.example.views.components.MyGrid; 

public function ti_focusOut():void { 
MyGrid(this.owner['parentDocument']).myCondition=Number(ti.text); 
MyGrid(this.owner['parentDocument']).dispatchEvent(new Event("myConditionChanged")); } 

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { if (this.owner['parentDocument'] && ti && MyGrid(this.owner['parentDocument']).myCondition) { ti.text=String(MyGrid(this.owner['parentDocument']).myCondition); 
} 
super.updateDisplayList(unscaledWidth,unscaledHeight); 
} 
]]> 
</fx:Script> 
<s:states> 
<s:State name="normal"/> 
</s:states> 
<s:TextInput id="ti" width="40" focusOut="ti_focusOut();"/> </s:GridItemRenderer> 


and here's MyGrid.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx"> 

<fx:Metadata> 
[Event(name="myConditionChanged", type="flash.events.Event")] </fx:Metadata> 

<fx:Script> 
<![CDATA[ 
... 
[Bindable] private var _myCondition:Number; public function set myCondition(value:Number):void { _myCondition=value; if (grid.columnHeaderGroup) { grid.columnHeaderGroup.layout.clearVirtualLayoutCache(); 
grid.columnHeaderGroup.invalidateDisplayList(); 
} 
grid.invalidateDisplayList(); 
} 
[Bindable] public function get myCondition():Number { return _myCondition; } ... 
]]> 
</fx:Script> 

<s:DataGrid id="grid"> 
<s:columns> 
<s:ArrayList> 
<s:GridColumn .../> 
<s:GridColumn id="myColumn" dataField="myCond" headerRenderer="com.example.views.itemRenderers.MyHeaderRenderer"/> 
<s:GridColumn .../> 
</s:ArrayList> 
</s:columns> 
</s:DataGrid> 
</s:Group> 

and finally, here is MyView.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<views:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
xmlns:components="com.example.views.components.*"> 
... 
<fx:Script> 
<![CDATA[ 
private function updateCondition():void { myGrid.myCondition=newValue; // how to force refresh of TextInput in header renderer with newValue? 
} 
private function onChange():void { 
... 
} 
]]> 
</fx:Script> 
<components:MyGrid id="myGrid" myConditionChanged="onChange();"/> 
... 
</views:View> 


________________________________ 

Edscha Holding GmbH 
Sitz der Gesellschaft: Remscheid 
Registergericht: Wuppertal, HRB 22889 
Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña, David Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz und Volker Weiss 

Vertretungsberechtigt sind nur Geschäftsführer und schriftlich Bevollmächtigte. 

Solely Managing Directors or employees with a written proxy have got power of representation. 

Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien ist vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung, Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte informieren Sie in diesem Fall unverzüglich den Absender und löschen Sie die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem System. Vielen Dank. 

The contents of this e-mail including any attachments are confidential and may be legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete this e-mail including any attachments from your system. Thank you. 


Re: AW: how to updateDisplayList() in custom headerRenderer? (help!)

Posted by mo...@comcast.net.
Thanks Olaf, 

I see how your method passes variable myCondition into the header renderer. 

But, doesn't this only occur when the data grid is created? That is, once the data grid already exists, how can I programmatically pass the variable myCondition into the header renderer sometime later (once myCondition changes)? 

For example, if I make variable myCondition bindable, would that cause it to auto-update the header renderer when myCondition changes? Or something else? 


----- Original Message -----

From: "Olaf Krüger" <OK...@edscha.com> 
To: "users, apache" <us...@flex.apache.org> 
Sent: Monday, December 1, 2014 6:59:35 AM 
Subject: AW: how to updateDisplayList() in custom headerRenderer? (help!) 

If your question is "How to pass additional data to an item renderer" this could work for you: 
(Take a look at the links to understand how it works) 

/** 
* Pass additional data to a Renderer 
* 
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/ClassFactory.html 
* @see http://stackoverflow.com/questions/528796/flex-sending-a-parameter-to-a-custom-itemrenderer 
*/ 
public static function createHeaderRenderer (renderer:Class, myCondition:Number):IFactory 
{ 
var factory:ClassFactory = new ClassFactory(renderer); 
factory.properties = { myCondition: myCondition }; 
return factory; 
} 

… 
<s:GridColumn headerRenderer="{createHeaderRenderer(MyHeaderRenderer, myCondition)}"/> 
… 





-----Ursprüngliche Nachricht----- 
Von: modjklist@comcast.net [mailto:modjklist@comcast.net] 
Gesendet: Montag, 1. Dezember 2014 15:20 
An: users, apache 
Betreff: Re: how to updateDisplayList() in custom headerRenderer? (help!) 

Hello again, I haven't got any response and was just hoping I could entice someone to review my question below. 

The code implements a textbook method to update the client model when someone changes the text in a spark TextInput located in a header renderer. This works fine. I just need to know a textbook method to go the other direction -- that is, how to programmatically update the text in the TextInput? I'm sure there's some standard way to do this, but I can't figure it out. Any hints much appreciated. I've tried to copy all the relevant code below. 

----- Original Message ----- 

From: modjklist@comcast.net 
To: "users, apache" <us...@flex.apache.org> 
Sent: Saturday, November 29, 2014 7:12:47 PM 
Subject: how to updateDisplayList() in custom headerRenderer? 

I'm using 4.12 SDK and trying to update a headerRenderer that includes a TextInput. Things works fine when the component is initialized. But thereafter, when I change the model such that the text showing in the TextInput box should change, the text doesn't change. 

Can someone help me figure out how to programmatically refresh the header renderer TextInput text using function updateCondition() in file MyView.mxml below? 

I've tried create a temp IFactory for the header renderer, null the original one, then save the temp back to the original, but this didn't work. Also tried invalidateDisplayList() on myGrid (didn't work either). 

Here's MyHeaderRenderer.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<s:GridItemRenderer 
xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
xmlns:itemRenderers="com.example.views.itemRenderers.*"> 

<fx:Script> 
<![CDATA[ 
import mx.collections.ArrayCollection; 
import com.example.views.components.MyGrid; 

public function ti_focusOut():void { 
MyGrid(this.owner['parentDocument']).myCondition=Number(ti.text); 
MyGrid(this.owner['parentDocument']).dispatchEvent(new Event("myConditionChanged")); } 

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { if (this.owner['parentDocument'] && ti && MyGrid(this.owner['parentDocument']).myCondition) { ti.text=String(MyGrid(this.owner['parentDocument']).myCondition); 
} 
super.updateDisplayList(unscaledWidth,unscaledHeight); 
} 
]]> 
</fx:Script> 
<s:states> 
<s:State name="normal"/> 
</s:states> 
<s:TextInput id="ti" width="40" focusOut="ti_focusOut();"/> </s:GridItemRenderer> 


and here's MyGrid.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx"> 

<fx:Metadata> 
[Event(name="myConditionChanged", type="flash.events.Event")] </fx:Metadata> 

<fx:Script> 
<![CDATA[ 
... 
[Bindable] private var _myCondition:Number; public function set myCondition(value:Number):void { _myCondition=value; if (grid.columnHeaderGroup) { grid.columnHeaderGroup.layout.clearVirtualLayoutCache(); 
grid.columnHeaderGroup.invalidateDisplayList(); 
} 
grid.invalidateDisplayList(); 
} 
[Bindable] public function get myCondition():Number { return _myCondition; } ... 
]]> 
</fx:Script> 

<s:DataGrid id="grid"> 
<s:columns> 
<s:ArrayList> 
<s:GridColumn .../> 
<s:GridColumn id="myColumn" dataField="myCond" headerRenderer="com.example.views.itemRenderers.MyHeaderRenderer"/> 
<s:GridColumn .../> 
</s:ArrayList> 
</s:columns> 
</s:DataGrid> 
</s:Group> 

and finally, here is MyView.mxml: 

<?xml version="1.0" encoding="utf-8"?> 
<views:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
xmlns:components="com.example.views.components.*"> 
... 
<fx:Script> 
<![CDATA[ 
private function updateCondition():void { myGrid.myCondition=newValue; // how to force refresh of TextInput in header renderer with newValue? 
} 
private function onChange():void { 
... 
} 
]]> 
</fx:Script> 
<components:MyGrid id="myGrid" myConditionChanged="onChange();"/> 
... 
</views:View> 


________________________________ 

Edscha Holding GmbH 
Sitz der Gesellschaft: Remscheid 
Registergericht: Wuppertal, HRB 22889 
Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña, David Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz und Volker Weiss 

Vertretungsberechtigt sind nur Geschäftsführer und schriftlich Bevollmächtigte. 

Solely Managing Directors or employees with a written proxy have got power of representation. 

Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien ist vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung, Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte informieren Sie in diesem Fall unverzüglich den Absender und löschen Sie die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem System. Vielen Dank. 

The contents of this e-mail including any attachments are confidential and may be legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete this e-mail including any attachments from your system. Thank you. 


AW: how to updateDisplayList() in custom headerRenderer? (help!)

Posted by Krüger, Olaf <OK...@edscha.com>.
If your question is "How to pass additional data to an item renderer" this could work for you:
(Take a look at the links to understand how it works)

/**
* Pass additional data to a Renderer
*
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/ClassFactory.html
* @see http://stackoverflow.com/questions/528796/flex-sending-a-parameter-to-a-custom-itemrenderer
*/
public static function createHeaderRenderer (renderer:Class, myCondition:Number):IFactory
{
        var factory:ClassFactory = new ClassFactory(renderer);
        factory.properties = { myCondition: myCondition };
        return factory;
}

…
<s:GridColumn  headerRenderer="{createHeaderRenderer(MyHeaderRenderer, myCondition)}"/>
…





-----Ursprüngliche Nachricht-----
Von: modjklist@comcast.net [mailto:modjklist@comcast.net]
Gesendet: Montag, 1. Dezember 2014 15:20
An: users, apache
Betreff: Re: how to updateDisplayList() in custom headerRenderer? (help!)

Hello again, I haven't got any response and was just hoping I could entice someone to review my question below.

The code implements a textbook method to update the client model when someone changes the text in a spark TextInput located in a header renderer. This works fine. I just need to know a textbook method to go the other direction -- that is, how to programmatically update the text in the TextInput? I'm sure there's some standard way to do this, but I can't figure it out. Any hints much appreciated. I've tried to copy all the relevant code below.

----- Original Message -----

From: modjklist@comcast.net
To: "users, apache" <us...@flex.apache.org>
Sent: Saturday, November 29, 2014 7:12:47 PM
Subject: how to updateDisplayList() in custom headerRenderer?

I'm using 4.12 SDK and trying to update a headerRenderer that includes a TextInput. Things works fine when the component is initialized. But thereafter, when I change the model such that the text showing in the TextInput box should change, the text doesn't change.

Can someone help me figure out how to programmatically refresh the header renderer TextInput text using function updateCondition() in file MyView.mxml below?

I've tried create a temp IFactory for the header renderer, null the original one, then save the temp back to the original, but this didn't work. Also tried invalidateDisplayList() on myGrid (didn't work either).

Here's MyHeaderRenderer.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:itemRenderers="com.example.views.itemRenderers.*">

<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import com.example.views.components.MyGrid;

public function ti_focusOut():void {
MyGrid(this.owner['parentDocument']).myCondition=Number(ti.text);
MyGrid(this.owner['parentDocument']).dispatchEvent(new Event("myConditionChanged")); }

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { if (this.owner['parentDocument'] && ti && MyGrid(this.owner['parentDocument']).myCondition) { ti.text=String(MyGrid(this.owner['parentDocument']).myCondition);
}
super.updateDisplayList(unscaledWidth,unscaledHeight);
}
]]>
</fx:Script>
<s:states>
<s:State name="normal"/>
</s:states>
<s:TextInput id="ti" width="40" focusOut="ti_focusOut();"/> </s:GridItemRenderer>


and here's MyGrid.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">

<fx:Metadata>
[Event(name="myConditionChanged", type="flash.events.Event")] </fx:Metadata>

<fx:Script>
<![CDATA[
...
[Bindable] private var _myCondition:Number; public function set myCondition(value:Number):void { _myCondition=value; if (grid.columnHeaderGroup) { grid.columnHeaderGroup.layout.clearVirtualLayoutCache();
grid.columnHeaderGroup.invalidateDisplayList();
}
grid.invalidateDisplayList();
}
[Bindable] public function get myCondition():Number { return _myCondition; } ...
]]>
</fx:Script>

<s:DataGrid id="grid">
<s:columns>
<s:ArrayList>
<s:GridColumn .../>
<s:GridColumn id="myColumn" dataField="myCond" headerRenderer="com.example.views.itemRenderers.MyHeaderRenderer"/>
<s:GridColumn .../>
</s:ArrayList>
</s:columns>
</s:DataGrid>
</s:Group>

and finally, here is MyView.mxml:

<?xml version="1.0" encoding="utf-8"?>
<views:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="com.example.views.components.*">
...
<fx:Script>
<![CDATA[
private function updateCondition():void { myGrid.myCondition=newValue; // how to force refresh of TextInput in header renderer with newValue?
}
private function onChange():void {
...
}
]]>
</fx:Script>
<components:MyGrid id="myGrid" myConditionChanged="onChange();"/>
...
</views:View>


________________________________

Edscha Holding GmbH
Sitz der Gesellschaft: Remscheid
Registergericht: Wuppertal, HRB 22889
Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña, David Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz und Volker Weiss

Vertretungsberechtigt sind nur Geschäftsführer und schriftlich Bevollmächtigte.

Solely Managing Directors or employees with a written proxy have got power of representation.

Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien ist vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung, Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte informieren Sie in diesem Fall unverzüglich den Absender und löschen Sie die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem System. Vielen Dank.

The contents of this e-mail including any attachments are confidential and may be legally privileged. If you are not the intended recipient, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete this e-mail including any attachments from your system. Thank you.