ItemRenderer Question
Hi all,
I have this Component with a DataGroup inside
<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init()" close="titlewindow1_closeHandler(event)">
<fx:Script>
<![CDATA[
import com.eworx.seven7eshop.views.presenters.CartPM;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
import mx.rpc.events.ResultEvent;
[Bindable]
public var model:CartPM;
[Bindable]
public var total:int;
private function init():void {
XML.ignoreWhitespace = true;
XML.prettyPrinting = false;
protected function titlewindow1_closeHandler(event:CloseEvent):void
PopUpManager.removePopUp(this);
protected function button1_clickHandler(event:MouseEvent):void
var params:Object = {};
var cartXML:XML = new XML("<order></order>");
for each (var item:Object in cartDg.dataProvider) {
var pId:String = item.pId;
var pName:String = item.pName;
var product:XML = <product pId={pId} pName={pName}></product>;
cartXML.appendChild(product);
params["orders"] = cartXML.toXMLString();
saveOrderServ.send(params);
model.emptyCart();
private function totalItems():void {
cartDg.dataProvider;
protected function httpservice1_resultHandler(event:ResultEvent):void
Alert.show("SAVED");
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="saveOrderServ" url="http://localhost/Seven7-Eshop-debug/rpc/saveOrders.php" method="POST" result="httpservice1_resultHandler(event)" />
</fx:Declarations>
<s:HGroup id="ordersHeader">
<s:Label id="shoppingCartLabel" text="Shopping Cart" />
<!--<s:Button label="Hide Details" />-->
</s:HGroup>
<s:Group id="marginHolder" width="1000" height="550">
<s:Rect width="100%" height="100%" radiusX="5" radiusY="5">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xD8B220" />
<s:GradientEntry color="0x986733" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<s:Rect width="100%" height="100%" radiusX="5" radiusY="5">
<s:fill>
<s:BitmapFill source="@Embed('garnish/denimPattern.png')" fillMode="repeat" />
</s:fill>
</s:Rect>
<s:VGroup top="25" left="25" width="100%" horizontalAlign="center">
<s:Scroller width="950" height="450">
<s:DataGroup id="cartDg" width="100%" height="100%"
dataProvider="{new ArrayCollection(model.cartProducts)}"
itemRenderer="CartListItemRenderer">
<s:layout>
<s:VerticalLayout gap="50" />
</s:layout>
</s:DataGroup>
</s:Scroller>
<s:Group>
<s:BitmapImage source="@Embed('garnish/cartCheckoutBorder.png')" />
<s:HGroup verticalAlign="middle">
<s:Label id="totalItemsPrice" text="items / € " />
<s:Button label="checkout" click="button1_clickHandler(event)" />
</s:HGroup>
</s:Group>
</s:VGroup>
</s:Group>
</s:TitleWindow>
And this itemrenderer with a datagrid inside
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="false">
<fx:Script>
<![CDATA[
import com.eworx.seven7eshop.events.CartEvent;
import mx.events.DataGridEvent;
[Bindable]
public var total:int = 0;
protected function color_sizes_itemEditBeginHandler(event:DataGridEvent):void
total = 0;
for each(var item:Object in color_sizes.dataProvider) {
for each(var cell:Object in item) {
if(cell > 0) {
total += cell;
]]>
</fx:Script>
<s:HGroup id="holder" gap="20">
<mx:Image source="{data.pImage}" />
<s:VGroup>
<s:Label id="orderTitle" text="{data.pName}" />
<s:Group width="100%">
<s:HGroup gap="20">
<s:Label id="orderProduct" text="{data.pCode}" />
<s:Label id="orderPrice" text="€ {data.pPrice}" />
</s:HGroup>
<s:Label id="previewTotal" text="Sum: {total} items / € {data.pPrice*total}" right="0" />
</s:Group>
<mx:DataGrid
id="color_sizes"
editable="true"
dataProvider="{data.rows}"
color="0x000000" columns="{data.columns}"
itemEditBegin="color_sizes_itemEditBeginHandler(event)"
/>
</s:VGroup>
</s:HGroup>
</s:ItemRenderer>
This Datagroup has a datagrid where the user can enter how many items want for each color/size. I can calculate the total items for each datagrid but I need to display the total of all datagrids in the parent component where the datagroup is.
How can I do that?
I would bypass the DataGrid all together. Using the DataGrid , you have to mess with itemrenderers and indexes ... not
very fun when one can avoid it. Instead , I would do my calculations off of the dataprovider. Then it becomes an elementary exercise of a for-loop and [Bindable] values.
Similar Messages
-
Flex AdvancedDataGrid - ColumnOrder With Formatter and ItemRenderer Question For Experts
I have a advanceddatagrid that has around 15 columns. Some are string,
some are numbers. I have shown 4 columns below.
The number columns have formatting done for zero precision and 2
digits precision. The itemRenderer is just to show Blue Color if the
number is +ve and Red Color if the number is -ve.
It looks something like below
<mx:columns>
<mx:AdvancedDataGridColumn dataField="Name" textAlign"left"/>
<mx:AdvancedDataGridColumn dataField="Time" textAlign="right"/>
<mx:AdvancedDataGridColumn dataField="Score" textAlign="right" formatter="{zeroPrecisionFormatter}" sortable="true" itemRenderer="ColorRenderer" />
<mx:AdvancedDataGridColumn dataField="Average" textAlign="right" headerWordWrap="true" formatter="{twoPrecisionFormatter}" itemRenderer="ColorRenderer" />
I am trying to save the users setting of column order when he closes
the application and reload with the same order when the user opens the
applications. I am using SharedObjects and below is the code.
for(var i:int=0; i< adgrid.columns.length;i++){
var columnObject:Object = new Object();
columnObject.columnDataField = adgrid.columns[i].dataField as String;
columnObject.columnHeader =adgrid.columns[i].headerText as String;
columnObject.width = adgrid.columns[i].width;
columnArray.push(columnObject);
and then I save the columnArray to SharedObject.
I retrive them using the below code
for(var i:int=0;i<columnArray.length;i++){
adgrid.columns[i].dataField =columnArray[i].columnDataField;
adgrid.columns[i].headerText =columnArray[i].columnHeader;
adgrid.columns[i].width = columnArray[i].width;
How can I save and reload the Formatter and ItemRenderer data .
I am having trouble saving the formatter and itemrenderer and
reloading it again.
I would really appreciate if you can shown the code.
How can I reshuffle the columns but can preserve all the properties of it to though sharedobject and recover it againI would bypass the DataGrid all together. Using the DataGrid , you have to mess with itemrenderers and indexes ... not
very fun when one can avoid it. Instead , I would do my calculations off of the dataprovider. Then it becomes an elementary exercise of a for-loop and [Bindable] values. -
Revision: 8435
Author: [email protected]
Date: 2009-07-07 15:38:03 -0700 (Tue, 07 Jul 2009)
Log Message:
While responding to a forum question, I realized ItemRenderer.getCurrentRendererState() was not documented. This is needed since developers will override this method to add/customize their renderer's state behavior if it differs from the default.
QA: No
Doc: No
Checkintests: Pass
Reviewer: me
Modified Paths:
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ItemRenderer .aslov2bugu, you said things the exact way I wanted to express them! It was like watching me talking to a SONY’s CEO.
I don’t really think they are not aware of the problems. SONY used to be the 27th largest company in the world, according to Forbes. They are now at the 456th place!!
They are aware of their problems and I think, the move to buy the remaining stocks from Ericsson, is a move to bounce back into the market. They found the right time, where the stock is too low and the economics around the globe don’t look promising enough. I have to recognize them, all the bad phases they went into this year … hacking attack, loss of their factory in London, global economic climate etc.
But these are not excuses good enough not to produce quality, reliable and technologically advanced goods. I think that SONY is not to blame for the bad course SE has had. I think this is what SONY wants to revert. They want to “embody” all their technology … BRAVIA engines (TV Tech), Walkman and Cybershot tech (using Carl Zeiss lenses), VAIO (Comp tech) and finally PS3. Ericsson tried to integrate them, unsuccessfully.
Overall, I thing SONY, did not have or did not attempt to have the control of SE, hence, the answer you got back from SONY “… anything related to SE must be posted on the website of SE”. I think they will bounce. Just give ‘em some time. I’m willing to give them time, but not too much though. Just because I’ve always loved this brand! -
ItemRenderer by gridCell, DataGrid questions
Hi All,
I am using a DataGrid with 3 columns to display data. 1st colum is just a label - non editable text, 2nd column is where I want to set/unset an itemRenderer (in this case a comboBox), 3rd column is a label - non editable or a text editable field.
Here is my problem, I want to be able to set/unset the item rederer by cell. Meaning, right now you can only set it by column but I don't want all my rows to have the combo box renderer, i want it to be based on some data. So, let say for row 0 is set to the comboBox redenrer but for row 1 it is just set to the default label renderer. All the examples I have found you can only set the special renderer to the entire column.
Also, for column 3 i have it define as editable (user can edit/enter text in the cell) but again you can set it to the entire column, it is posible to set it by cell.
Many thanks in advance!You can try overriding createColumnItemRenderer, but some folks find it easier to have a single renderer that will show a combobox or label based on the data.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui -
I have following code and got a compilation error ("possiblely called an undefined function") because the <mx:Image ...> in the <mx:itemRenderer > could not see the defination of "aMethod" method:
<mx:Form ....>
<mx:Script><![CDATA[
private function aMethod(evt:Event):void {
// code...
]]></mx:Script>
<mx:Canvas label="Tile View" width="100%" height="100%" >
<mx:TileList id="photosTileList" dataProvider="{this.photoDP}" width="100%" height="100%" >
<mx:itemRenderer >
<mx:Component>
<mx:Image horizontalAlign="center" source="{data.url.text()}"
toolTip="{data.caption.text()}" width="55" height="38" complete="aMethod(event)"/> <!-- It causes the error -->
</mx:Component>
</mx:itemRenderer>
</mx:TileList>
<mx:Image .... complete="aMethod(event)"/> <!-- It is OK here -->
</mx:Canvas>
</mx:Form>
I do not know why the inline <mx:Image> inside <mx:itemRenderer> can not see the "aMethod" function defination in the same mxml file.
Any suggestions?You need outerDocument, and the method cannot be private, it should be public:
complete="outerDocument.aMethod(event)"
If this post answers your question or helps, please mark it as such.
Greg Lafrance - Flex 2 and 3 ACE certified
www.ChikaraDev.com
Flex / AIR Development, Training, and Support Services -
Passing data from an XML object to an itemRenderer
I'm trying to color the background of a column in a datagrid and have found a sample file that illustrate the concept. However, the sample has data stored in an arrayCollection whereas mine is in an XML object. The problem is that the data in the sample file is apparently automatically passed to the itemRenderer (shown below: note the trace statement). My XML object does not appear to automatically pass data to the itemRenderer. So my questions are:
1. Is there a simple way to pass data stored in an XML object to an itemRenderer
or
2. Should I convert my XML to an arrayCollection? If so, what's the best way to do this-- I've tried the following, but without success:
<mx:Model id="xmldata" source="example3.xml"/>
<mx:ArrayCollection id="myAC" source="{ArrayUtil.toArray(xmldata.Example1)}" />
Here's what the xml looks like:
<TABLE>
<EXAMPLE1>
<difficulty> 0.5 </difficulty>
<discrimination> 0.7 </discrimination>
<item> 3 </item>
</EXAMPLE1>
</TABLE>
Here's the itemRenderer:
<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml">
<!--
This item renderer simply extends Label and overrides the updateDisplayList function to
draw a gradient-filled rectangle. The colors in the gradient are determined from the
data.
-->
<mx:Script>
<![CDATA[
import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.Graphics;
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
super.updateDisplayList(unscaledWidth,unscaledHeight);
var m:Matrix = new Matrix();
m.createGradientBox(unscaledWidth,unscaledHeight);
var g:Graphics = graphics;
trace("data.col3="+data.col3)
var colors:Array = (data.col3 < 2000 ? [0x0000CC,0x0000FF] : [0x00CC00,0x00FF00]);
g.clear();
g.beginGradientFill(GradientType.LINEAR, colors, [0.2,0.6], [0,255], m);
// the rectangle is drawn a little high and a little tall to compensate for the gap
// the DataGrid introduces between rows.
g.drawRect(0, -2, unscaledWidth, unscaledHeight+4 );
g.endFill();
]]>
</mx:Script>
</mx:Label>This sample code should answer your question of how to bring data into the renderer automatically. It comes in via the DataGrid dataProvider and then you refer to it in the renderer as data.XYZ, where XYZ is the field in the XML with the data. See FB 3 help sys on e4x syntax.
------------------ mainapp.mxml --------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="srvc.send();">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.XMLListCollection;
[Bindable] private var xlc:XMLListCollection;
private function dataHandler(evt:ResultEvent):void{
xlc = new XMLListCollection(evt.result..EXAMPLE1 as XMLList);
]]>
</mx:Script>
<mx:HTTPService id="srvc" url="data2.xml" result="dataHandler(event)"
resultFormat="e4x"/>
<mx:DataGrid dataProvider="{xlc}">
<mx:columns>
<mx:DataGridColumn headerText="Difficulty" dataField="difficulty"/>
<mx:DataGridColumn headerText="Discrimination" dataField="discrimination"/>
<mx:DataGridColumn headerText="Item" itemRenderer="MyLabel"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
----------- MyLabel.mxml --------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.Graphics;
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth,unscaledHeight);
this.text = data.col3;
var m:Matrix = new Matrix();
m.createGradientBox(unscaledWidth,unscaledHeight);
var g:Graphics = graphics;
var colors:Array = (data.col3 < 2000 ? [0x0000CC,0x0000FF] : [0x00CC00,0x00FF00]);
g.clear();
g.beginGradientFill(GradientType.LINEAR, colors, [0.2,0.6], [0,255], m);
g.drawRect(0, -2, unscaledWidth, unscaledHeight+4 );
g.endFill();
]]>
</mx:Script>
</mx:Label>
------------ data2.xml ----------------
<?xml version="1.0" encoding="utf8"?>
<TABLE>
<EXAMPLE1>
<difficulty> 0.5 </difficulty>
<discrimination> 0.7 </discrimination>
<col3> 3 </col3>
</EXAMPLE1>
</TABLE> -
Using a canvas as an itemrenderer - how to access the datafield?
Yes... another ItemRenderer related question...
So I have this advancedDataGrid of which I dynamically
generate the columns in actionscript. Each of these columns get
their own datafield.
This code works well, since all the data displays nicely
where I want it to be.
However, in the columns there are numbers from like 0 to 10,
these are put there by the default itemrenderer by using the
datafield. Instead of just displaying these numbers, I'd like to
use a canvas as an itemrenderer to draw something in the box based
on the value of the number. So all I need to access in my Canvas is
the value that is parsed by the datafield.
I thought to do so by overriding public function set
data(value:Object):void
But what does value contain? I tried doing something with it
but I keep getting errors. Does value just contain the entire
dataProvider? Or is there a way to acces just the number that would
be put on that position in the grid if I wouldn't be using a custom
itemrenderer at all?
I've searched tons of blogs but haven't found the exact
answer to my question yet.
Many thanks in advance."Lvw2000" <[email protected]> wrote in
message
news:gnucks$8kh$[email protected]..
> Yes... another ItemRenderer related question...
>
> So I have this advancedDataGrid of which I dynamically
generate the
> columns in
> actionscript. Each of these columns get their own
datafield.
>
> This code works well, since all the data displays nicely
where I want it
> to be.
>
> However, in the columns there are numbers from like 0 to
10, these are put
> there by the default itemrenderer by using the
datafield. Instead of just
> displaying these numbers, I'd like to use a canvas as an
itemrenderer to
> draw
> something in the box based on the value of the number.
So all I need to
> access
> in my Canvas is the value that is parsed by the
datafield.
>
> I thought to do so by overriding public function set
> data(value:Object):void
>
> But what does value contain?
It contains the information needed for the entire row. Just
put a break
point in the code in your override function and then run the
application in
debug mode. Use the variables window to inspect the value.
> I tried doing something with it but I keep
> getting errors.
Are the errors related to the value or are they related to
something else,
such as trying to set properties on subcomponents that have
not been
instatiated yet.
> Does value just contain the entire dataProvider? Or is
there a
> way to acces just the number that would be put on that
position in the
> grid if
> I wouldn't be using a custom itemrenderer at all?
Look at implementing IDropInListItemRenderer and then look at
listData.label.
HTH;
Amy -
How to set a checkbox in a datagrid's itemrenderer
Hello.
I've a spark datagrid. In a column there is a checkbox. In another column (I need to add it dynamically with actionscript) I've another checkbox (inside an itemrenderer). Cliccking on the first checkbox, I need to enable/disable the second checkbox.
More in general I need to interact not just with a checkbox but some other components inside columns added dynamically.
My question is: how to get (with actionscript) components inside an itemrender created dynamically?
Follow details related to the checkbox case:
Here my spark datagrid columns definitions:
<s:columns>
<s:ArrayList>
<s:GridColumn headerText="Azioni" resizable="false" sortable="false" width="49" ....../>
<s:GridColumn headerText="Iscritto" width="60" itemRenderer="renderers.EventoPersonaCheckBoxRenderer" dataField="iscritto"/>
<s:GridColumn id="personaEventoGridPersonaColumn" headerText="Persona" labelFunction...../>
<s:GridColumn id="personaEventoGridSocietaColumn" headerText="Societa" labelFunction..../>
</s:ArrayList>
</s:columns>
As you can see there si an itemrender. A checkbox is inside it.
I also need to add dynamically new colums to my datagrid. Each new column has an itemrender with a checkbox.
here the code to add a new columns:
private function createNewColumn():void
var newColumn:GridColumn = new GridColumn("column TEST");
newColumn.itemRenderer = new ClassFactory(NewColumnCheckBoxRenderer);
var cols:ArrayList = new ArrayList();
cols =eventoPersonaGrid.columns as ArrayList;
cols.addItem(newColumn);
The itemrenderer is the following:
<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" clipAndEnableScrolling="true">
<fx:Script>
<![CDATA[
import events.CheckBoxEvent;
protected function eventoSubscribedCB_clickHandler(event:MouseEvent):void
data.iscritto = ! data.iscritto;
dispatchEvent(new CheckBoxEvent(CheckBoxEvent.UPDATE,data.iscritto));
]]>
</fx:Script>
<s:layout>
<s:HorizontalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<s:CheckBox id="eventoSubscribedCB" selected="{data.iscritto}" click="eventoSubscribedCB_clickHandler(event)"/>
</s:GridItemRenderer>
As explained above cliccking on the checkbox inside datagrid definition, I need to change the checkbox properties that is located inside an itemrenderer.
How can I do that?
Is there a way to get the itemrenderer and checkbox references by the selectedItem datagrid property?
thank you
PbesiThanks harUI.
Ok, I've to change how to face this kind of problems. Reading some articles I understood that there is not an itemrenderer for each row in a data grid. Instead, there are some itemrenderes (the number is the same of the visible rows in a datagrid) and they are applied on the other rows during the datagrid scroll. There no reason to try to get an itemrender instance. So the only way is to add these data inside a dataitem and get them with the "data" property. Ok, just is sounds strange for some properties to be carried on a valueobject because they aren't properties related to the data model (for example the infromation "checkbox is enabled/disabled"). Anyway it works. Thank you.
Pbesi -
Image.source in ItemRenderer works in Windows but not Mac
I have a Flex (AIR) application that is giving me problems on
the Mac. In one of the
Datagrids, I am using an ItemRenderer with an image control.
Some code in the
"set data(value:Object)" function assigns a file path as the
source of the image
control as follows.
imgThumb.source =
File.documentsDirectory.resolvePath("pdqtemp").nativePath +
"/" + data.strJPGFileName;
This works correctly in Windows , but not on the Mac.
In this case, the path resolves to the following on the Mac.
/Users/brian/Documents/pdqtemp/artist_01t.jpg
I have verified that the file is in the right place and when
using the path in
the command line console, it correctly addresses that
directory and file. I
don't normally develop apps for the Mac so I am sure there is
something I am
missing.
Any ideas?
Thanks for your help.Hi Jed,
Thanks for responding
That is the exact path assigned to the Source of the Image
control. However, it isn't exactly a trace of the Image.Source
property.
The code in question is attached
The alert shows the path I originally posted and shows that
the fileImgThumb.exists returns False.
As I mentioned, this works perfectly in Windows. There is
some code elsewhere in the app that creates the thumbnail. That
does work on the Mac as the thumbnail image is created and saved
where expected.
I am not sure what I might be doing wrong.
Thanks for your help,
Sid -
Set textSelectionColor of itemrenderer in my combobox
Hi all,
First of all, all apologies if this question were already discussed around. I serached and found nothing. On the web, all that I have found didn't really help.
I defined an itemRenderer for a combobox
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" styleName="plain" >
<mx:Style source="styles.css" />
<mx:Script>
<![CDATA[
private function check():void{
if(data.status=='ko'){
lbl.styleName='ko';
]]>
</mx:Script>
<mx:Label id="lbl"
text="{data.name}"
valueCommit="check()"
/>
</mx:VBox>
And then my combobox
<mx:ComboBox itemRenderer="listItem" labelField="name" />
I have styles the combobox component like this
ComboBox
font-family:"HelveticaNeueLT Pro 57 Cn";
font-size:12;
color:#FFFFFF;
alternatingItemColors: #555555, #383838;
rollOverColor:#F9B41F;
selectionColor:#2D2D2D;
textRollOverColor:white;
textSelectedColor:#F9B41F;
Everything is fine to the exception of the textRollOverColor & textSelectedColor properties which are ignored by the itemRenderer.
So I am looking for a way to do this.
I was advised to create a custom combobox, so I did
package custom
import mx.controls.ComboBox;
import mx.events.DropdownEvent;
public class customCombobox extends ComboBox
private var DD:ComboBox;
public function customCombobox()
//TODO: implement function
super();
But I can't get how to deal with the events (rollOver/selected) so I can style the label of the itemRenderer. I am so stuck for days on that.
So thanks in advance to anyone who could help exiting this deadend
Just for info, it needs to be mx only, not spark.
LoicThe renderer is responsible for setting the text color using those styles.
Look in mx.controls.listClasses.ListItemRenderer to see how it does it. -
imglist = arraycollection which contains names of images
which are coming from database
myimg = array of images
all images are stored in newfolder
how to use tilelist itemrenderer for imagesHi Jed,
Thanks for responding
That is the exact path assigned to the Source of the Image
control. However, it isn't exactly a trace of the Image.Source
property.
The code in question is attached
The alert shows the path I originally posted and shows that
the fileImgThumb.exists returns False.
As I mentioned, this works perfectly in Windows. There is
some code elsewhere in the app that creates the thumbnail. That
does work on the Mac as the thumbnail image is created and saved
where expected.
I am not sure what I might be doing wrong.
Thanks for your help,
Sid -
Dynamic datagrid rowHeight and itemRenderer problem
Hi guys,
Long time listener; first time caller....
I have had a look around the forums here and i can see there are a lot of similar issues to the one i'm currently having but not so many solutions. Not sure if i'll have any better luck with my question but here goes...
My issue is to do with the row height of a datagrid row not matching up properly with the height of the custom iterm renderer used on a column.
The item renderer consists of an HBox containing an image and a textArea. The image will not always be present and the text area can contain a couple of words or many lines of text.
I have overridden the measure function of the item render in which i am manually setting the HBox's height and measuredHeight.
Problem is that i have to find some way of triggering a redraw of the datagrid AFTER if have set the item renderers height, but i dont seem to be able to directly access the in-line renderer from the parent class.
If anyone could throw any suggestions my way it would be greatly appreciated!
thanks '
DaveOk so here's the sample code...
****Renderer*****
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox
horizontalAlign="
left" verticalAlign="
middle" horizontalGap="
0"verticalGap="
0"xmlns:mx="
http://www.adobe.com/2006/mxml" horizontalScrollPolicy="
off"verticalScrollPolicy="
off"width="
100%" height="
100%"resize="measure()"
borderColor="
green"borderStyle="
solid"
>
<mx:Metadata>[
Event(name="gridRowHeightChange", type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import mx.events.ResizeEvent;
import flash.events.Event;
Bindable] public var showLocalPartImage:Boolean = false;
override public function set data(value:Object):void
super.data = value;
lblPartNum.text = data.label;}
override protected function measure():void
super.measure();
if(lblPartNum.text != "" && lblPartNum.width > 0) {
lblPartNum.validateNow(); lblPartNum.mx_internal::getTextField().autoSize = TextFieldAutoSize.LEFT;
lblPartNum.height =
this.height = measuredHeight = lblPartNum.mx_internal::getTextField().height;
dispatchEvent(
new Event("gridRowHeightChange")); }
]]>
</mx:Script>
<mx:Image id="imgLocal" horizontalAlign="center" verticalAlign="middle" visible="false" width="{0}"/>
<mx:TextArea id="lblPartNum" width="{this.width - imgLocal.width - 4}" height="100%" editable="false" verticalScrollPolicy="off" />
</mx:HBox>
****EndRenderer*****
****DataGrid****
public function measureGrid(event:Event):void{
shoppingCart.removeEventListener(DataGridEvent.COLUMN_STRETCH, measureGrid);
shoppingCart.invalidateList();
shoppingCart.addEventListener(DataGridEvent.COLUMN_STRETCH, measureGrid);
<mx:DataGrid id="shoppingCart"width="
100%" height="100%"dataProvider="
{_order.orderItems}"allowMultipleSelection="
true"sortableColumns="
true"variableRowHeight="
true"doubleClickEnabled="
true"doubleClick="selectPartHandler(event)"
paddingRight="
5"editable="
false"
>
<mx:columns>
<mx:DataGridColumn width="22" minWidth="20" sortable="false" editable="false"/>
<mx:DataGridColumn width="22" minWidth="20" sortable="false" editable="false"/>
<mx:DataGridColumn minWidth="240" width="270" dataTipField="description" dataField="description" headerText="Description"editable="
false" wordWrap="true">
<mx:itemRenderer>
<mx:Component>
<controls:DescriptionShoppingCartRenderer showLocalPartImage="
{!(outerDocument.displayUnderline)}" gridRowHeightChange="{outerDocument.measureGrid(event)}">
</controls:DescriptionShoppingCartRenderer>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
****EndDataGrid****
Unfortunately the whole code is much too large to fit in here, but here are the main working parts.
I hope this helps.
What i am getting when running this is strange. When i run the first time and when i resize a column, the row height is incorrect, but then when i just click the 'column stretch' arrow (ie the space between the column headers) and dont actually resize at all, the row heights re-calculate and they fit perfectly.
This makes me think that i need to trigger this event manually AFTER the itemRenderer has been calculated.
EDIT: forgot to add the measureGrid function -
Tree component bug (?) and some questions
Hi! I have some problems and questions about tree component.
Problems:
1. I have an expanded tree with ~300 items. Each item label
displayed in 2-3 strings. After QUICK tree scrolling using mouse
wheel (I make 3-5 scrolls) for most of items displayed only last
string and one empty string :(
Bug of tree renderer? Is it fixable?
Questions:
1. Can I have font color X for tree item 1 and font color Y
for tree item 2?
2. I have a tree with ~300 items. Expand/Collapse tree
operations takes 5 to 10 seconds on Core2Duo. Is it possible to
speed up this operations?
Code:Hello.
About problem 1.
I faced this problem several times, cann't understand the
problem. May be it's a bug.
Questions.
1. Of course you can. Write itemRenderer for this.
2. Tree has effects for expanding and collapse events, you
can reduce times for them. -
Datagrid and multiple ItemRenderer
What I would like to do and haven't been successful is add a column to a Datagrid at runtime. Each cell in that column is going to be different based upon user data. The first column is populated based upon a user query then another query (i.e. RESTful query) is made to mashup some data.
I wanted a button (mashup data) to appear in the column enabled if data was available and disabled if data was not available.
I was doing something like this:
My MXML file has this:
<mx:DataGrid id="dg" dataProvider="{ModelLocator.getInstance().list}" itemClick="itemClickHandler(event)" left="10" right="0" bottom="0" top="50" editable="true" >
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name" editable="true" />
<mx:DataGridColumn headerText="Data" dataField="someData" itemRenderer="ActionButtonItemRenderer" />
</mx:columns>
</mx:DataGrid>
ActionButtonItemRenderer.as file:
public class ActionButtonItemRenderer extends Button
public function ActionButtonItemRenderer()
super();
label = "Show Data";
override public function set data(value:Object):void {
if (null == value.myData) {
label = "";
this.enabled = false;
// Handle the search button event.
override protected function clickHandler(event:MouseEvent):void
// Code omitted here...
It works but when I use my mouse wheel to scroll through the records the buttons get all hosed up and the enabled buttons become disabled. It's weird.
Thanks!You create an ArrayCollection or XMLListCollection and populate it initially with perhaps data that would represent "no data".
Then if your queries return real data, the dataProvider object now "has data".
The itemRenderer does the appropriate thing if there is not is no data.
You don't generate the button in the dataProvider, you just get the label and visible property value etc. from the dataProvider.
If this post answers your question or helps, please mark it as such.
Greg Lafrance - Flex 2 and 3 ACE certified
www.ChikaraDev.com
Flex / AIR Development, Training, and Support Services -
Ellipsis (...) in dataGrid itemRenderer
If you want a line of text in a datagrid cell to end with an ellipsis (...) when it's too long for its cell, you can set the column's item renderer to be "mx.control.Label" and that works. The entry looks like this:
Here is my line of dat...
But here's my problem.
I have created my own item renderer which is an HBox containing an image and a label. But the label doesn't truncate with the ellipsis ... when the data is too long, it simply chops the end off the displayed text.
So my question is this. How can I get the ellipsis ... to appear for the label in my item renderer? I'm using a datagrid with scaleable column widths so I can't set a fixed width on the label which would work, I know.
Cheers,
NeilThanks for your suggestion.
It didn't work but inspired me to play around with minWidth and maxWidth.
What I eventually got to work was:
maxWidth="
{this.width-28}"
...on the Label in the HBox. I'm assuming that "this" here refers to the ItemRenderer.
I had to put in the "-28" bit or it wouldn't do it. If you want more padding on the right of the ellipsis (so it doesn't hit the edge of the cell) increase the 28 to something higher. Use a lower value for less padding.
Hope this helps someone else like it did me.
Cheers,
Neil
Maybe you are looking for
-
CUCM 8.6 call busy between SIP phones and thirdparty phones
Hi Everybody, I have the following error on my logs: Invalid Disconnect Cause(cause=47), No Reason Header Appended 14:46:50.091 |//SIP/SIPCdpc(3,74,281707)/ci=144600614/ccbId=35257792/scbId=0/getXCiscoViPRFallbackIDAndDTMFKey: Device type 8, Pstn Fal
-
Sun ONE Studio IDE ???
Hello, I have a JSP project to which has to be created in Sun One Studio. On internet, while searching to download it, I find pages for version 5 which says, Soory no download is availbale at present and for 4 it shows how to migrate Sun One Studio p
-
HT201302 error message do not have write access to my pictures
error message do not have write access
-
Help needful, fi-co-copa documents relation needed.
hi, how to get the fi corresponding co document and also copa document. for suppose fi document (belnr) is 20010305 if it is having corresponding co document. till here i am getting the logic. after knowing that this particular fi has the co document
-
I have just recently started using the Lightroom 5 trial. I have edited photos that I would like to export to use for Christmas cards but I am not having luck moving them out of Lightroom? Anyone else have this problem? I am using a Mac Pro and tr