Problem updateDisplayList in itemRenderer
Hello!
I directed at you, because I'm a little lost.
(Sorry for my English)
I'm relatively new to Flex and I'm finding some
problems, which I try out.
One of the biggest I have is the following:
I made a custom chart, from a
<mx:LineChart> with different rendereres. In the method
updateDisplayList () for each one, drawing the elements that need.
The graph contains data of a measure, for the last 3 months
but only shows 20 days. You can scroll through the graph
clicking an arrow I added outside of the graph.
When I create the graph, passed several times by the updateDisplayList ();
CustomAxisHorizontalRenderer (2 times)
CustomAxisVerticalRenderer (2 times)
CustomGridRenderer (1 time)
CustomCircleItemRenderer (40 times for the 40 data
I have three months)
Not because he needs to spend 40 times by the
CustomCircleItemRenderer.updateDisplayList if I only see 10 data, and if
is because when I move one day backward, re-
call again around the same time renderers.
Not if you have something to do with cacheAsBitmap or invalidateDisplayList
I am not using.
All this is making the application (and I use this component
enough) is slow, and I this desperate with Flex.
Hopefully you can help me
Some of the spark containers have a useVirtualLayout property that will allow your itemRenderers to be recycled if set to true. See http://help.adobe.com/en_US/flex/using/WS64909091-7042-4fb8-A243-8FD4E2990264.html#WS486D1 976-E12C-4654-B330-3DF3B23614F6 for more info. I'm not sure if LineChart supports this property in flex 4.x, if it doesn't you may have to base your component off of something that does.
Similar Messages
-
Problem with Datagrid itemrenderer with a Datagrid
Hi all,
I have this kind of a structure. I try to use a datagrid item renderer in a data grid column. However when I try to move rows inside the same datagrid I experience a problem. When my datagrid loads first it seems correct, but when I drag and drop a row in the same datagrid inner datagrids start to be drew in wrong rows. I checked the DB but there are no mistakes in DB records. Problem is with rendering. I suppose inner datagrids trying to draw to early or datagrid component is trying to reuse the itemrenderer. I could not find any solutions for that. Any help will be greatly appreciated..
<mx:DataGridColumn width="130" editable="false"
headerText="{resourceManager.getString('resources', 'acl.content')}">
<mx:itemRenderer>
<mx:Component>
<ACLInnerDataGrid rowCount="3" dragEnabled="true" dropEnabled="false"
x="0" y="0" editable="true" dragInitiatorId="catGrid"
filterGroupName="content" remoteDestination="zend"
remoteSource="ACLFilterParamService" showHeaders="false"
creationComplete="this.init();">
<columns>
<mx:DataGridColumn dataField="id" editable="false" visible="false"/>
<mx:DataGridColumn dataField="ruleId" editable="false" visible="false"/>
<mx:DataGridColumn dataField="filterKey" editable="false" visible="false"/>
<mx:DataGridColumn dataField="param" editable="false" visible="false"/>
<mx:DataGridColumn dataField="name" editable="true"/>
</columns>
</ACLInnerDataGrid>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
Thanks in advance.I have attached the item renderer component source code.
-
Problem with Checkbox ItemRenderer in a DataGrid
Hello Everyone,
I'm using a datagrid with two columns, which is used as a data entry grid. The first column has a simple text input field and the 2nd column has a checkbox as an itemrenderer. On creationComplete event, I'm passing an arraycollection as the dataprovider for this datagrid. The arraycollection:
<mx:ArrayCollection id="psAC">
<mx:source>
<mx:Array>
<mx:Object PaText="line1" PaCheckbox="0" />
<mx:Object PaText="line2" PaCheckbox="0" />
<mx:Object PaText="line3" PaCheckbox="1" />
<mx:Object PaText="line4" PaCheckbox="0" />
<mx:Object PaText="line5" PaCheckbox="0" />
</mx:Array>
</mx:source>
</mx:ArrayCollection>
There is a datagrid (dGa) in the main application. On click of this, a pop up window comes up which has the same datagrid layout(i.e, 2 columns). And this is where the data is entered. Here, if the user checks the check box, I have assigned a value of '1' for the 2nd column of the arraycollection. THis code(below) works fine.
<datagrid in pop up window>
<mx:DataGridColumn headerText="Best Possible Action?" textAlign="center" width="200" editable="false">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox>
<mx:Script>
<![CDATA[
override public function set data(value:Object):void{
if(value.PaCheckbox == 1){
this.selected = true;
}else{
this.selected = false;
]]>
</mx:Script>
<!--<mx:change>
<![CDATA[
if(this.selected == true){
data.PaCheckbox = 1;
}else{
data.PaCheckbox = 0;
]]>
</mx:change>-->
</mx:CheckBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
But I would also need to set the PaCheckbox value to 0 or 1, based on teh check condition of the check box. I tried using change event (commented in the code above). But there I get an error: Cannot access a property or method of a null object reference. I checekd in debug mode, there the data object is null! Can you please help me on how to pass back the values(0 o 1) to my arraycollection, based on the checkbox's status?
Cheers,
Deepakheyo,
I solved it.....
i was missing this line of code super.data = value; in the ovverriden function...Once we have this line, the data object will have teh field names and their values in it, which can be accessed on the change event... -
DragEnabled problem with ADG ItemRenderer
I'm using an AdvancedDataGrid with a regular ArrayCollection binding and DragEnabled "true". I'm having a vertical scroll also since I've plenty of items in the grid now. With normal ADG rendering, I can scroll to the bottom most items automatically while dragging any item, or, can auto-scroll to toppest items of the list (which eventually was out of the screen rows). But this is not working (auto-scroll) if I'm using any item renderer for the rows. I'm using a normal VBox kind of component as item renderer, with background color. The grid component not auto-scroll anymore while dragging any item to the beneath of the screen shown items. I've fate up try fixing this problem. Any workarounds?
Item Renderers are" recycled" by Flex as they scroll in and out of view. So when you change a button's selected state to true and then scroll around, that renderer ends up getting recycled to another item and causes this to look wrong.
The trick is you have to make the item renderer update itself. there are many ways. One sure-fire way I tend to fall back on is to add a property to the data provider, then bind to that in the renderer-changing it as needed.
1) When you set up your data provider, add a new property "toggled" as a boolean:
private function init(event:Event):void
//populate array with 50 items
for (var i:uint=1; i<51; i++)
itemAC.addItem({label:"B"+i, toggled:false});
2) Now change your renderer, binding the selected property of the button to this new prop.
Also, add a bit of code to the change event of the button:
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="150" height="150">
<mx:Button id="btn" label="{data.label}" x="25" y="66" toggle="true" width="100"
change="{data.toggled = btn.selected}" selected="{data.toggled}" >
</mx:Button>
</mx:Canvas>
Result: the item renderer now looks to its data property to decide how to behave, and will have the proper state (selected or not) no matter if it gets recycled to another item in your data provider or not.
HTH -
Problem with checkbox itemrenderer in combobox
I am rendering checkbox in combox(dynamically). when i check
any item(s) in my combox and then on selecting(checking the
combobox's item) another item(s) or on scrolling item list in
combobox, it shows improper checkd items. i .e the checkd list
displayed is totally different, with randomnly checkd items in that
list.
please help me out?hi,
i think you have to try itemEditor instead of
itemRenderer -
Itemrenderer with images doesn't work correctly if variableRowHeight="true"?
Hi all,
I have a problem to use itemrenderer in my project:
I have to show some images in one of my DataGridColumn:
<mx:DataGridColumn id="datasetcolumn" headerText="DataSet"
dataField="dataSetList"
width="240"itemRenderer="DataSetRenderer"/>
The dataSetList is an arraycollection of images;
I use Tile as the itemrederer, My DataSetRenderer is:
<?xml version="1.0" encoding="utf-8"?>
<mx:Tile xmlns:mx="
http://www.adobe.com/2006/mxml"
horizontalScrollPolicy="off" width="90%" height="100%" >
<mx:Metadata>
[Event(name="showCaddwgNOVWebDataset",
type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import mx.controls.Image;
import mx.controls.AdvancedDataGrid;
import mx.core.IFlexDisplayObject;
import CETEvent.*;
import view.util.*;
import mx.collections.ArrayCollection;
[Bindable] public var myarr:ArrayCollection = new
ArrayCollection();
override public function set data(value:Object):void{
super.data = value;
myarr = value.datasetList;
this.myrep.dataProvider = myarr as ArrayCollection;
]]>
</mx:Script>
<mx:Repeater id="myrep" visible="true" >
<mx:Label text="{myrep.currentItem.itIconName}"/>
<mx:Image id="datasetImg"
source="{myrep.currentItem.itIconName}"
useHandCursor="true" buttonMode="true" mouseChildren="false"
toolTip="{myrep.currentItem.itName}"/>
</mx:Repeater>
</mx:Tile>
The problem is:
Whenever you change the column size or scroll down the
datagrid,
the images will be added again.
if the datasetlist is changed the old images doesn't clean up
and
all the images messed up
Any suggestion is appretiated!
Thanks in advanceI loved Ben's suggestion because it promised to be a low-effort workaround, but, alas, I get the same problem: "lvlib is already loaded from this path...".
I tried Olivia's workaround for CAR 124214. It worked great for the simple lvproj that is posted above. (Hooray!) It didn't work so well in my real project, that has about 30 lvlibs and lvclasses. About 3/4 of the way through the save, I got a compiler error and LabView crashed. (Boo!) I submitted the crash log on this, but it's hard to imagine how anyone in R&D could make any progress debugging this without the source code. (And I can't submit the source because I can't export a copy of it!)
Anyway, thank you very much Ben and Olivia for your suggestions. I have lvclasses embedded in lvlibs (primarily for organizational reasons) and since LabView tanked while saving one of those, perhaps the workaround doesn't work in this case. I may try again after removing the lvclasses from the lvlibs so that the hierarchy is flatter.
-Rob -
Defining Namespace of an itemRenderer
Hello,
I want to create an instance of an itemRenderer by using
ActionScript, like:
.. passingVar="{new itemRenderer()}" ...
But the problem is, the itemRenderer relies on a sub
directory.
I tried to define a namespace for datagrid itemrenderers
like: xmlns:mx.controls.dataGridClasses.DataGridItemRend
erer="item_renderer.*"
This would maybe work if I used mx-tags for defining the
renderer, but I do it by ActionScript.
I have no idea how to set another namespace, so "new
itemRenderer()" would find the correct mxml-Script.
Any ideas? Thanks.I found the solution:
import item_renderer.*;
... passingVar="{new ClassFactory(dataGridTextAreaView)}"... -
Hi,
i have a s:list filled by webservice. I use a ListItemRenderer to show images in this list.
In the oncreationcomplete event of the renderer i create a loader to load an image.
Everything is ok.
Now i need to clear the list by using list.dataProvider.removeAll() .
The list ist cleared and i want to fill the list again with different images, so i call the webservice. The list is getting filled again but with wrong images.
The problem ist, the Itemrenderer creationcomplete event is not fired cause of the ItemRenderers are still alive.
I have used the profile to check what happens.
after the first call to fill the list i have 40 itemrenderers. after removeAll() i still have 40 itemrenderers.
Now i fill the list with 60 images, i have 60 itemrenderers.
How can i remove all the unneeded itemrenderers ?
Thanks
MichaelHi Michael,
Itemrenderers get recycled and the creationComplete in Itemrenderers is fired only once as they are not created again but recycled.
So you shouldn't load your images in creationComplete event instead override the set data function which is called for each itemRenderer when ever your dataProvider changes and in this function you can load images by creating a loader.
So in your itemRenderer override the set data() function as shown below..
override public function set data(value:Object):void
var loader:Loader = new Loader();
loader.url = someurl;
loader.load();
Thanks,
Bhasker -
Hello,
I have to display into a data grid, in Flex 2, 2 columns:
first column ( "Images") must contain a picture with an object and
second column (" quantity") must contain the amount of that object
that I want to buy. The problem is that I must take the name of the
image from an .xml file, specified like this:
<mx:DataGrid id="obj" dataProvider="{ObjList}" > where
ObjList is the .xml file with <name/>
<picture_address/> etc.
The second column must contain a textbox so I can input a
number of items for each picture ( can be also a combobox where
from I can select some value, from 1 to 20 for example).
I've searched the Internet and I haven't found a solution
yet. Please give me a link or a solution for this problem.
Tudoruse itemrenderes.... the example below shows how to add an
image.... you can do the same thing with a text box or combo box
<mx:DataGridColumn width="10" headerText="Image">
<mx:itemRenderer>
<mx:Component>
<mx:Canvas width="100%" height="100%">
<mx:Image verticalCenter="0" horizontalCenter="0"
source="{data.picture_adress}""/>
</mx:Canvas>
</mx:Component>
</mx:itemRenderer> -
Item renderer in datagrid with actionscript
Hi
I want to implement a datagrid similar to the one given int
the starting flex examples but in actionscript. I am having a
problem with the itemRenderer. I can't figure it out how I cam
create a imagerender in a datagridcolumn.
My code is:
var dataG:DataGrid = new DataGrid();
dataG.dataProvider = xmlList;
var coluna:DataGridColumn = new DataGridColumn();
coluna.dataField="nome";
coluna.headerText="Title";
var coluna2:DataGridColumn = new DataGridColumn();
coluna2.dataField="thumbnail";
coluna2.headerText="Title";
var imagem:Image = new Image();
imagem.height = 75;
imagem.source = "../tb/"+instrumentos.thumbnail+".jpg";
//HERE RELIES MY PROBLEM -HOW TO ASSOCIATE AN IMAGE TO THE
ITEM RENDERER
coluna2.itemRenderer = new ClassFactory(imagem);
var lalala:Array = new Array();
lalala.push(coluna);
lalala.push(coluna2);
dataG.columns = lalala;
thanks in advance"jahh_drum" <[email protected]> wrote in
message
news:ghcs5u$p2d$[email protected]..
> Hi
>
> I want to implement a datagrid similar to the one given
int the starting
> flex
> examples but in actionscript. I am having a problem with
the itemRenderer.
> I
> can't figure it out how I cam create a imagerender in a
datagridcolumn.
>
> My code is:
>
> var dataG:DataGrid = new DataGrid();
> dataG.dataProvider = xmlList;
>
> var coluna:DataGridColumn = new DataGridColumn();
> coluna.dataField="nome";
> coluna.headerText="Title";
>
> var coluna2:DataGridColumn = new DataGridColumn();
> coluna2.dataField="thumbnail";
> coluna2.headerText="Title";
>
>
> var imagem:Image = new Image();
> imagem.height = 75;
> imagem.source = "../tb/"+instrumentos.thumbnail+".jpg";
>
> //HERE RELIES MY PROBLEM -HOW TO ASSOCIATE AN IMAGE TO
THE ITEM
> RENDERER
> coluna2.itemRenderer = new ClassFactory(imagem);
>
> var lalala:Array = new Array();
> lalala.push(coluna);
> lalala.push(coluna2);
>
> dataG.columns = lalala;
ClassFactory takes a class, not an instance.
Try something like:
foo:ClassFactory = new ClassFactory(Image)
foo.properties= {height=75,
source:"../tb/"+instrumentos.thumbnail+".jpg"};
coluna2.itemRenderer = foo;
Note that using a ClassFactory this way will give you the
same image in
every renderer to start out with. However, I believe that
image
itemRenderers by default will take their source from the data
property when
that gets set.
HTH;
Amy -
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 -
Forcing custom itemRenderer to updateDisplayList?
Hi, I'm new to flex, and was having some trouble.
In my project, I have a DataGrid, and a
BarChart->BarSeries. The DataGrid and the BarSeries share the
same DataProvider. I've made a custom itemRenderer, so that I can
click on Bars in the BarSeries and have them be highlighted in
black. This is done by having the itemRenderer listen for a CLICK
event, changing a variable that stores what color I want, then
calling invalidateDisplayList() to have updateDisplayList update
the display.
Since DataGrid and BarSeries share the same DataProvider,
elements in the DataGrid match up with elements in the BarSeries.
Therefore, I would like to be able to have a user click on an item
in the DataGrid, and have the associated bar in the BarSeries chart
become highlighted. However, I can't find a way to get the
itemRenderer to call updateDisplayList from outside of the
itemRenderer itself. I thought that calling invalidateDisplayList()
using the BarChart's id or the BarSeries id would force the
itemRenderer for the BarSeries to call updateDisplayList() and
update itself, but by using the debug feature, I have found that it
does not do this. Does anyone have any advice for how I would be
able to click on a DataGrid item and have it highlight the
corresponding item in the BarChart?
Thanks!Hi, I'm new to flex, and was having some trouble.
In my project, I have a DataGrid, and a
BarChart->BarSeries. The DataGrid and the BarSeries share the
same DataProvider. I've made a custom itemRenderer, so that I can
click on Bars in the BarSeries and have them be highlighted in
black. This is done by having the itemRenderer listen for a CLICK
event, changing a variable that stores what color I want, then
calling invalidateDisplayList() to have updateDisplayList update
the display.
Since DataGrid and BarSeries share the same DataProvider,
elements in the DataGrid match up with elements in the BarSeries.
Therefore, I would like to be able to have a user click on an item
in the DataGrid, and have the associated bar in the BarSeries chart
become highlighted. However, I can't find a way to get the
itemRenderer to call updateDisplayList from outside of the
itemRenderer itself. I thought that calling invalidateDisplayList()
using the BarChart's id or the BarSeries id would force the
itemRenderer for the BarSeries to call updateDisplayList() and
update itself, but by using the debug feature, I have found that it
does not do this. Does anyone have any advice for how I would be
able to click on a DataGrid item and have it highlight the
corresponding item in the BarChart?
Thanks! -
Drag-n-Drop problem in DataGrid with custom ItemRenderer
Hi,
I am trying to use a DataGrid to set the ordering of a group
of images.
I want to do this with a DataGrid which will show me some
properties of
the images in different columns including a thumbnail of the
image. The
problem is when I use any custom renderer for any column, the
draging is
not working. It works fine when I don't use any ItemRenderer.
My code looks something like this:
<mx:DataGrid dragEnabled= "true" dropEnabled= "true"
dragMoveEnabled= "true">
<mx:columns>
<mx:DataGridColumn headerText="Thumb" itemRenderer=
"component. GridImageRenderer"/>
<mx:DataGridColumn headerText="Current name" width="100"
itemRenderer= "component. NameRenderer" />
<mx:DataGridColumn headerText="New name" width="150"
dataField="nameNew" />
</mx:columns>
</mx:DataGrid>
Can anyone please give me any clue how to fix this?
Regards,
~ ArifHello again, BinaryDigit.
I thought we need to apply Drag n drop API for this case.
Without wasting too much time,
I tried out as your source code from the previous reply,,,
Instead of getting it clearly, I got another Confusion... (pardon me)
Let me clarify this with the examples given,
I try to adopt previous source code
and it was this detail;
1) Taking the X and Y coordinate (from the mouseEvent) Plus jLabel1 coordinate (both X and Y).
2) Positioning a Coordinate taken to JLabel1
3) Passing the Coordinate taken to jLabelX, and jLabelY.
The problem found was;
if we make 3rd become comments, now the jLabel1
could works!
I mean, jLabel1 could be dragged to another Coordinate (by dragging it to another location)
But,
if we un-comments the 3rd source code,
The effect would be no movement of the jLabel1.
BinaryDigit, is this related to the layout you mentioned before?
Correct, DarrylBurke! :D
I thought also the same thing,
but setLocation() give me another Confusion....
the coordinate seems taking its basement as a reference.
I mean, the jLabel Coordinate's is referenced
from the panel where the jLabel is attached to,
rather than the Coordinate's of the base jFrame (main base -what should I call this?)
Sorry, the Details number three (3) is my preference, Since I wanted to see the X, Y movements also. -
Hello,
I have a requirement to display an image in some rows in the
datagrid based on a flag obtained from the database. To achieve
this, I am using a custom itemrenderer for that particular column
and on a simple check if the value obtained for that particular row
is 1 then I show the image, else I leave it blank (i.e set the
image visibility to false).
Here is a snippet of the code:
Custom ItemRenderer
<mx:HBox .... creationComplete="init();">
<mx:Script>
<![CDATA[
public function init( ):void {
// Check if the flag is 0 or 1 to determine whether to show
or hide the image
if(data.@FLAG == 0) {
img.visible = false;
]]>
</mx:Script>
<mx:Image id="img" source="something.gif" />
</mx:HBox>
Main Application
<mx:Application .........>
<mx:DataGrid dataProvider="{myXML.item}" ... >
<mx:columns>
<mx:DataGridColumn dataField="@FLAG" headerText="Image"
itemRenderer="CustomItemRenderer" />
......... // Other columns
</mx:columns>
<mx:DataGrid>
</mx:Application>
This code seems to work to a certain level. However, here are
some problems that i'm facing and would like to know if this is the
right approach:
1. The check to determine whether to show the image doesn't
function well. It shows the image when the flag is 0 and sometimes
doesn't show the image when the flag is 1.
2. Upon scrolling or sorting of the datagrid the results of
the column randomly get messed up losing the images for the ones it
had before scrolling or sorting and sometimes placing the image in
another row it does not belong to.
Can anyone please guide me if they have worked on a similar
requirement and how it can be achieved. My feeling is that I am
performing the check in the wrong method. I tried doing it by
overriding the set data method but that has the scroll problem and
eventually makes all the images visible initially disappear after
scrolling or sorting.
Any help will be much appreciated.
Thank you.Override the set data property and move the code written in
init() method there:
override public function set data(value:Object):void {
super.data = value;
// Check if the flag is 0 or 1 to determine whether to show
or hide the image
if(data.@FLAG == 0) {
img.visible = false;
once it works, and there is no reason why it shouldn't, read
up more on life cycle of renderers in the docs.
ATTA -
ItemRenderer and DataGrid Problem
Hi guys.
I'm on creating a small app that simply pulls information
from an XML file, displays it in a DataGrid then allows the user to
filter and search it. First things first though; I'll explain what
I have so far then detail my problem.
I get the XML file via HTTPService then place the results in
a Bindable ArrayCollection. When the Datagrid's source is set to
that ArrayCollection it works fine. What I am initially trying to
do is use an itemRenderer in one of the columns that displays lines
of text depending on the values of the current row.
For example, the structure of my XML file is (roughly):
<content>
<name>Name1</name>
<description>Description Goes Here</description>
<audience1>yes</audience1>
<audience2>no</audience2>
<audience3>yes</audience3>
</content>
So what I am trying to do is group the audiences that each
piece of "content" has a yes value to. So under the "Audiences"
column in the datagrid, the above content would say
"Audience1
Audience3"
as it has a yes value in between audience 1 and 3. I've tried
writing very basic code within the itemRenderer whereby I override
the public function set data and do some checks there but it never
seems to work right. I've tried using Arrays within that to store
the current audiences but I clearly haven't got the right format
for that.
There must be a more efficient way of doing this. I'm fairly
new to both Flex and AS3 (been using AS2 quite a while now) but I
have a feeling there would be some way to store each row's audience
list in an array/object/model so I can refer to it later (I'm
intending to filter these results by audience type later so I think
I will HAVE to do it this way eventually). I've read quite a few
tutorials and guides but I honestly don't know where to look
anymore, none of them seem to cover this specific problem.
I hope this makes sense to you guys and any guidance you
could give me would be greatly appreciated.
CheersLabelFunction produces a display-only column.
To filter, you will need to use the underlying data.
Another solution to consider is to create a custom item
class. Loop over the xmllist and build instances of the class,
populating the properties from the xml.
have a property who's value is calculated based on the
audience properties values. Since it is a "real" data property in
each item, you can filter on it directly.
Tracy
Maybe you are looking for
-
Is it possible to schedule updates for a specific time of day like 12am?
Is it possible to schedule updates for a specific time of day like 12am?
-
ORA-13349: polygon boundary crosses itself
Hi, I have the following scenario in a polygon ("o" is polygon boundary): oooooooooooooooooooooooooooooooooooo oo#########################oo oo#########################oo oo##################ooooooooooo oo##################oo oo#########ooooooooooooo
-
Display users of a transaction code
How can I display a listing of user-ids with access to the Transport Management system? The t-code for the Transport Management System is " stms "
-
Approval Task for role assignment
Hello again, is there any manual for approval tasks with the SAP Provisioning Framework? There is a task group called Request new business role, but if I use this, the approver approves the request, but the status of the role assignment is "in proces
-
HT204088 why do i keep getting charged on my credit card for itunes when i havent used it
Why do i keep getting charged for stuff on itunes when i havent purchased any thing in a while