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" <okrue...@edscha.com> 
To: "users, apache" <users@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: modjkl...@comcast.net [mailto:modjkl...@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: modjkl...@comcast.net 
To: "users, apache" <users@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. 

Reply via email to